#include <base/interfaces/performance-interface.h>
#include <base/interfaces/vsync-monitor-interface.h>
#include <base/interfaces/kernel-trace-interface.h>
-#include <internal/common/render-surface-impl.h> // @todo move to base/interfaces
+#include <render-surface-impl.h> // @todo move to base/interfaces
namespace Dali
// INTERNAL INCLUDES
#include <base/interfaces/egl-interface.h>
-#include <internal/common/render-surface-impl.h> // needed for Dali::Internal::Adaptor::RenderSurface
+#include <render-surface-impl.h> // needed for Dali::Internal::Adaptor::RenderSurface
namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "abort-handler.h"
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+AbortHandler* AbortHandler::gInstance(NULL);
+
+AbortHandler::AbortHandler(boost::function<void(void)> callback)
+: mSignalMask( 0 ),
+ mCallback( callback )
+{
+ DALI_ASSERT_ALWAYS( gInstance == NULL && "Only one instance of abort handler allowed" );
+ gInstance = this;
+
+ memset( mSignalOldHandlers, 0, sizeof(SignalHandlerFuncPtr) * (_NSIG-1));
+}
+
+AbortHandler::~AbortHandler()
+{
+ int signum;
+ for ( signum = 1; signum < _NSIG; signum++ )
+ {
+ if ( mSignalMask & (1 << (signum-1) ) )
+ {
+ // set signals back to default handling
+ signal( signum, mSignalOldHandlers[signum-1] );
+ }
+ }
+ gInstance = NULL;
+}
+
+bool AbortHandler::AbortOnSignal( int signum )
+{
+ bool status = false;
+
+ if ( signum < _NSIG )
+ {
+ SignalHandlerFuncPtr signalHandlerPrevious = signal( signum, &AbortHandler::SignalHandler );
+
+ if ( SIG_ERR != signalHandlerPrevious )
+ {
+ mSignalOldHandlers[signum-1] = signalHandlerPrevious;
+ mSignalMask |= ( 1 << (signum-1) );
+ status = true;
+ }
+ }
+ return status;
+}
+
+void AbortHandler::SignalHandler( int signum )
+{
+ if( gInstance )
+ {
+ if( gInstance->mCallback )
+ {
+ gInstance->mCallback();
+ }
+ }
+}
+
+} // Adaptor
+} // Internal
+} // Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H__
+#define __DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <signal.h>
+#include "application.h"
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+/**
+ * Class to listen to system signals and trigger an abort callback
+ * when they occur.
+ *
+ * This class maintains a process wide singleton, as the signal(2) system
+ * call is process specific, not thread specific.
+ *
+ * Currently, this precludes having multiple DALi instances in the same process.
+ */
+class AbortHandler
+{
+public:
+ /**
+ * Constructor
+ * @param[in] callback The function to call when abort signals occur
+ */
+ AbortHandler(boost::function<void(void)> callback);
+
+ /**
+ * Destructor
+ */
+ ~AbortHandler();
+
+ /**
+ * Add a signal you want to be handled by this abort handler.
+ * @param[in] signum The signal number (from signum.h)
+ * @return true if the signal handler was installed ok
+ */
+ bool AbortOnSignal( int signum );
+
+private:
+ /**
+ * Signal handler - Called when signal is received.
+ * Stops the application.
+ */
+ static void SignalHandler( int signum );
+
+ /**
+ * Default constructor - undefined
+ */
+ AbortHandler();
+
+ /**
+ * Copy constructor - undefined
+ */
+ AbortHandler(const AbortHandler& rhs);
+
+ /**
+ * Assignment operator - undefined
+ */
+ AbortHandler& operator=(const AbortHandler& rhs);
+
+private:
+ typedef void (*SignalHandlerFuncPtr )( int );
+
+ // _NSIG comes from the signal.h linux system header, defining the number of signals.
+ SignalHandlerFuncPtr mSignalOldHandlers[_NSIG-1];
+ unsigned long long mSignalMask;
+
+ boost::function<void(void)> mCallback;
+
+ static AbortHandler* gInstance;
+};
+
+} // Namespace Adaptor
+} // Namespace Internal
+} // Namespace Dali
+
+#endif // __DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "accessibility-gesture-detector.h"
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/events/gesture-requests.h>
+#include <accessibility-manager-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+AccessibilityGestureDetector::AccessibilityGestureDetector()
+: PanGestureDetectorBase(Vector2::ZERO, Integration::PanGestureRequest(), NULL),
+ mGestureHandler(NULL),
+ mPanning(false)
+{
+}
+
+AccessibilityGestureDetector::~AccessibilityGestureDetector()
+{
+}
+
+void AccessibilityGestureDetector::SetGestureHandler(AccessibilityGestureHandler& handler)
+{
+ mGestureHandler = &handler;
+}
+
+void AccessibilityGestureDetector::EmitPan(const Integration::PanGestureEvent gesture)
+{
+ if( mGestureHandler )
+ {
+ if(gesture.state == Gesture::Started)
+ {
+ mPanning = true;
+ }
+
+ if( mPanning )
+ {
+ mGestureHandler->HandlePanGesture(gesture);
+
+ if( (gesture.state == Gesture::Finished) ||
+ (gesture.state == Gesture::Cancelled) )
+ {
+ mPanning = false;
+ }
+ }
+ }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ACCESSIBILITY_GESTURE_DETECTOR_H__
+#define __DALI_INTERNAL_ACCESSIBILITY_GESTURE_DETECTOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+#include <events/pan-gesture-detector-base.h>
+#include <adaptor-impl.h>
+#include <accessibility-gesture-handler.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+class Core;
+struct TouchEvent;
+struct PanGestureRequest;
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Detects an accessibility pan gesture and sends it to the gesture handler.
+ */
+class AccessibilityGestureDetector : public PanGestureDetectorBase
+{
+public:
+
+ /**
+ * Constructor
+ */
+ AccessibilityGestureDetector();
+
+ /**
+ * Virtual destructor.
+ */
+ virtual ~AccessibilityGestureDetector();
+
+ /**
+ * Set the handler to handle accessibility gestures.
+ * @param[in] handler The Accessibility gesture handler.
+ * @note Handlers should remove themselves when they are destroyed.
+ */
+ void SetGestureHandler(AccessibilityGestureHandler& handler);
+
+private:
+
+ /**
+ * Emits the pan gesture event to the gesture handler.
+ * @param[in] gesture The pan gesture event.
+ */
+ virtual void EmitPan(const Integration::PanGestureEvent gesture);
+
+private:
+
+ AccessibilityGestureHandler* mGestureHandler; ///< The pointer of accessibility gesture handler
+ bool mPanning; ///< Keep track of panning state, when panning is occuring, this is true.
+};
+
+typedef IntrusivePtr<AccessibilityGestureDetector> AccessibilityGestureDetectorPtr;
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ACCESSIBILITY_GESTURE_DETECTOR_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "accessibility-manager-impl.h"
+
+// EXTERNAL INCLUDES
+#include <vconf.h>
+
+#include <dali/public-api/dali-core.h>
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/gesture-requests.h>
+#include "system-settings.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gAccessibilityManagerLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_MANAGER");
+#endif
+
+void AccessibilityOnOffNotification(keynode_t* node, void* data)
+{
+ AccessibilityManager* manager = static_cast<AccessibilityManager*>(data);
+ int isEnabled = 0;
+ vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &isEnabled);
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled?"ENABLED":"DISABLED");
+
+ if(isEnabled == 1)
+ {
+ manager->EnableAccessibility();
+ }
+ else
+ {
+ manager->DisableAccessibility();
+ }
+}
+
+BaseHandle Create()
+{
+ BaseHandle handle( AccessibilityManager::Get() );
+
+ if ( !handle && Adaptor::IsAvailable() )
+ {
+ Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
+ Dali::AccessibilityManager manager = Dali::AccessibilityManager( new AccessibilityManager() );
+ adaptorImpl.RegisterSingleton( typeid( manager ), manager );
+ handle = manager;
+ }
+
+ return handle;
+}
+TypeRegistration ACCESSIBILITY_MANAGER_TYPE( typeid(Dali::AccessibilityManager), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
+
+} // unnamed namespace
+
+Dali::AccessibilityManager AccessibilityManager::Get()
+{
+ Dali::AccessibilityManager manager;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::AccessibilityManager ) );
+ if(handle)
+ {
+ // If so, downcast the handle
+ manager = Dali::AccessibilityManager( dynamic_cast< AccessibilityManager* >( handle.GetObjectPtr() ) );
+ }
+ }
+
+ return manager;
+}
+
+Vector2 AccessibilityManager::GetReadPosition() const
+{
+ return mReadPosition;
+}
+
+void AccessibilityManager::SetActionHandler(AccessibilityActionHandler& handler)
+{
+ mActionHandler = &handler;
+}
+
+void AccessibilityManager::SetGestureHandler(AccessibilityGestureHandler& handler)
+{
+ if( mAccessibilityGestureDetector )
+ {
+ mAccessibilityGestureDetector->SetGestureHandler(handler);
+ }
+}
+
+bool AccessibilityManager::HandleActionClearFocusEvent()
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionClearFocus signal in first, ClearAccessibilityFocus for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionClearFocusSignalV2.Empty() )
+ {
+ mActionClearFocusSignalV2.Emit( handle );
+ }
+ }
+
+ if( mActionHandler )
+ {
+ ret = mActionHandler->ClearAccessibilityFocus();
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ Dali::TouchEvent touchEvent(timeStamp);
+ touchEvent.points.push_back(point);
+
+ /*
+ * In order to application decide touch action first,
+ * emit ActionScroll signal in first, AccessibilityActionScroll for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionScrollSignalV2.Empty() )
+ {
+ mActionScrollSignalV2.Emit( handle, touchEvent );
+ }
+ }
+
+ Integration::TouchEvent event;
+ if (mCombiner.GetNextTouchEvent(point, timeStamp, event))
+ {
+ // Process the touch event in accessibility gesture detector
+ if( mAccessibilityGestureDetector )
+ {
+ mAccessibilityGestureDetector->SendEvent(event);
+ ret = true;
+ }
+ }
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
+{
+ bool ret = false;
+
+ Dali::TouchEvent touchEvent(timeStamp);
+ touchEvent.points.push_back(point);
+
+ if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionTouch(touchEvent);
+ }
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionBackEvent()
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionBack signal in first, AccessibilityActionBack for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionBackSignalV2.Empty() )
+ {
+ mActionBackSignalV2.Emit( handle );
+ }
+ }
+
+ if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionBack();
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+void AccessibilityManager::HandleActionEnableEvent()
+{
+ EnableAccessibility();
+}
+
+void AccessibilityManager::HandleActionDisableEvent()
+{
+ DisableAccessibility();
+}
+
+void AccessibilityManager::EnableAccessibility()
+{
+ if(mIsEnabled == false)
+ {
+ mIsEnabled = true;
+
+ if( mActionHandler )
+ {
+ mActionHandler->ChangeAccessibilityStatus();
+ }
+
+ //emit status changed signal
+ Dali::AccessibilityManager handle( this );
+ mStatusChangedSignalV2.Emit( handle );
+ }
+}
+
+void AccessibilityManager::DisableAccessibility()
+{
+ if(mIsEnabled == true)
+ {
+ mIsEnabled = false;
+
+ if( mActionHandler )
+ {
+ mActionHandler->ChangeAccessibilityStatus();
+ }
+
+ //emit status changed signal
+ Dali::AccessibilityManager handle( this );
+ mStatusChangedSignalV2.Emit( handle );
+
+ // Destroy the TtsPlayer if exists.
+ Dali::Adaptor& adaptor = Dali::Adaptor::Get();
+ Adaptor::GetImplementation(adaptor).DestroyTtsPlayer(Dali::TtsPlayer::SCREEN_READER);
+ }
+}
+
+bool AccessibilityManager::IsEnabled() const
+{
+ return mIsEnabled;
+}
+
+void AccessibilityManager::SetIndicator(Indicator* indicator)
+{
+ mIndicator = indicator;
+}
+
+AccessibilityManager::AccessibilityManager()
+: mIsEnabled(false),
+ mActionHandler(NULL),
+ mIndicator(NULL),
+ mIndicatorFocused(false)
+{
+ int isEnabled = 0;
+ vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &isEnabled);
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled?"ENABLED":"DISABLED");
+
+ if(isEnabled == 1)
+ {
+ mIsEnabled = true;
+ }
+ else
+ {
+ mIsEnabled = false;
+ }
+
+ vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification, this );
+
+ mAccessibilityGestureDetector = new AccessibilityGestureDetector();
+}
+
+AccessibilityManager::~AccessibilityManager()
+{
+ vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification );
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ACCESSIBILITY_MANAGER_H__
+#define __DALI_INTERNAL_ACCESSIBILITY_MANAGER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/events/touch-point.h>
+#include <dali/integration-api/events/touch-event-combiner.h>
+#include <accessibility-manager.h>
+
+// INTERNAL INCLUDES
+#include <accessibility-action-handler.h>
+#include <accessibility-gesture-handler.h>
+#include <indicator-impl.h>
+#include <accessibility-gesture-detector.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * This class detects to accessibility action
+ */
+class AccessibilityManager : public Dali::BaseObject
+{
+public:
+
+ typedef Dali::AccessibilityManager::AccessibilityActionSignalV2 AccessibilityActionSignalV2;
+ typedef Dali::AccessibilityManager::AccessibilityActionScrollSignalV2 AccessibilityActionScrollSignalV2;
+
+ // Creation
+
+ /**
+ * Constructor.
+ */
+ AccessibilityManager();
+
+ /**
+ * Get an instance of the AccessibilityManager.
+ * @return The instance of the AccessibilityManager.
+ */
+ static Dali::AccessibilityManager Get();
+
+ // Public API
+
+ /**
+ * Turn on accessibility action
+ * This method should be called by vconf callback
+ */
+ void EnableAccessibility();
+
+ /**
+ * Turn off accessibility action
+ * This method should be called by vconf callback
+ */
+ void DisableAccessibility();
+
+ /**
+ * @copydoc Dali::AccessibilityManager::IsEnabled()
+ */
+ bool IsEnabled() const;
+
+ /**
+ * @copydoc Dali::AccessibilityManager::GetReadPosition() const
+ */
+ Vector2 GetReadPosition() const;
+
+ /**
+ * @copydoc Dali::AccessibilityManager::SetActionHandler()
+ */
+ void SetActionHandler(AccessibilityActionHandler& handler);
+
+ /**
+ * @copydoc Dali::AccessibilityManager::SetGestureHandler()
+ */
+ void SetGestureHandler(AccessibilityGestureHandler& handler);
+
+ /**
+ * Set the Indicator
+ */
+ void SetIndicator(Indicator* indicator);
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionNextEvent()
+ */
+ bool HandleActionNextEvent(bool allowEndFeedback = true);
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionPreviousEvent()
+ */
+ bool HandleActionPreviousEvent(bool allowEndFeedback = true);
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionActivateEvent()
+ */
+ bool HandleActionActivateEvent();
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionReadEvent()
+ */
+ bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionReadNextEvent()
+ */
+ bool HandleActionReadNextEvent(bool allowEndFeedback = true);
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionReadPreviousEvent()
+ */
+ bool HandleActionReadPreviousEvent(bool allowEndFeedback = true);
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionUpEvent()
+ */
+ bool HandleActionUpEvent();
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionDownEvent()
+ */
+ bool HandleActionDownEvent();
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionClearFocusEvent()
+ */
+ bool HandleActionClearFocusEvent();
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionScrollEvent()
+ */
+ bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionTouchEvent()
+ */
+ bool HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp);
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionBackEvent()
+ */
+ bool HandleActionBackEvent();
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionEnableEvent()
+ */
+ void HandleActionEnableEvent();
+
+ /**
+ * @copydoc Dali::AccessibilityManager::HandleActionDisableEvent()
+ */
+ void HandleActionDisableEvent();
+
+public: // Signals
+
+ /**
+ * @copydoc Dali::AccessibilityManager::StatusChangedSignal
+ */
+ AccessibilityActionSignalV2& StatusChangedSignal()
+ {
+ return mStatusChangedSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::AccessibilityManager::ActionNextSignal
+ */
+ AccessibilityActionSignalV2& ActionNextSignal()
+ {
+ return mActionNextSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::AccessibilityManager::ActionPreviousSignal
+ */
+ AccessibilityActionSignalV2& ActionPreviousSignal()
+ {
+ return mActionPreviousSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::AccessibilityManager::ActionActivateSignal
+ */
+ AccessibilityActionSignalV2& ActionActivateSignal()
+ {
+ return mActionActivateSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::AccessibilityManager::ActionOverSignal
+ */
+ AccessibilityActionSignalV2& ActionOverSignal()
+ {
+ return mActionOverSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::AccessibilityManager::ActionReadSignal
+ */
+ AccessibilityActionSignalV2& ActionReadSignal()
+ {
+ return mActionReadSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::AccessibilityManager::ActionReadNextSignal
+ */
+ AccessibilityActionSignalV2& ActionReadNextSignal()
+ {
+ return mActionReadNextSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::AccessibilityManager::ActionReadPreviousSignal
+ */
+ AccessibilityActionSignalV2& ActionReadPreviousSignal()
+ {
+ return mActionReadPreviousSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::AccessibilityManager::ActionUpSignal
+ */
+ AccessibilityActionSignalV2& ActionUpSignal()
+ {
+ return mActionUpSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::AccessibilityManager::ActionDownSignal
+ */
+ AccessibilityActionSignalV2& ActionDownSignal()
+ {
+ return mActionDownSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::AccessibilityManager::ActionClearFocusSignal
+ */
+ AccessibilityActionSignalV2& ActionClearFocusSignal()
+ {
+ return mActionClearFocusSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::AccessibilityManager::ActionBackSignal
+ */
+ AccessibilityActionSignalV2& ActionBackSignal()
+ {
+ return mActionBackSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::AccessibilityManager::ActionScrollSignal
+ */
+ AccessibilityActionScrollSignalV2& ActionScrollSignal()
+ {
+ return mActionScrollSignalV2;
+ }
+
+private:
+
+ // Destruction
+
+ /**
+ * Destructor.
+ */
+ virtual ~AccessibilityManager();
+
+ // Undefined
+ AccessibilityManager( const AccessibilityManager& );
+ AccessibilityManager& operator=( AccessibilityManager& );
+
+private:
+
+ Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
+
+ bool mIsEnabled; ///< enable/disable the accessibility action
+ Vector2 mReadPosition; ///< ActionRead position
+
+ AccessibilityActionHandler* mActionHandler; ///< The pointer of accessibility action handler
+
+ AccessibilityGestureDetectorPtr mAccessibilityGestureDetector; ///< The accessibility gesture detector
+
+ Indicator* mIndicator; ///< The indicator
+ bool mIndicatorFocused; ///< Whether the Indicator is focused
+
+ AccessibilityActionSignalV2 mStatusChangedSignalV2;
+ AccessibilityActionSignalV2 mActionNextSignalV2;
+ AccessibilityActionSignalV2 mActionPreviousSignalV2;
+ AccessibilityActionSignalV2 mActionActivateSignalV2;
+ AccessibilityActionSignalV2 mActionOverSignalV2;
+ AccessibilityActionSignalV2 mActionReadSignalV2;
+ AccessibilityActionSignalV2 mActionReadNextSignalV2;
+ AccessibilityActionSignalV2 mActionReadPreviousSignalV2;
+ AccessibilityActionSignalV2 mActionUpSignalV2;
+ AccessibilityActionSignalV2 mActionDownSignalV2;
+ AccessibilityActionSignalV2 mActionClearFocusSignalV2;
+ AccessibilityActionSignalV2 mActionBackSignalV2;
+ AccessibilityActionScrollSignalV2 mActionScrollSignalV2;
+
+public:
+
+ // Helpers for public-api forwarding methods
+
+ inline static Internal::Adaptor::AccessibilityManager& GetImplementation(Dali::AccessibilityManager& manager)
+ {
+ DALI_ASSERT_ALWAYS( manager && "AccessibilityManager handle is empty" );
+
+ BaseObject& handle = manager.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::AccessibilityManager&>(handle);
+ }
+
+ inline static const Internal::Adaptor::AccessibilityManager& GetImplementation(const Dali::AccessibilityManager& manager)
+ {
+ DALI_ASSERT_ALWAYS( manager && "AccessibilityManager handle is empty" );
+
+ const BaseObject& handle = manager.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::AccessibilityManager&>(handle);
+ }
+
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ACCESSIBILITY_MANAGER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <accessibility-manager.h>
+
+// INTERNAL INCLUDES
+#include <accessibility-manager-impl.h>
+
+namespace Dali
+{
+
+const char* const AccessibilityManager::SIGNAL_STATUS_CHANGED( "accessibility-status-changed" );
+const char* const AccessibilityManager::SIGNAL_ACTION_NEXT( "accessibility-action-next" );
+const char* const AccessibilityManager::SIGNAL_ACTION_PREVIOUS( "accessibility-action-previous" );
+const char* const AccessibilityManager::SIGNAL_ACTION_ACTIVATE( "accessibility-action-activate" );
+const char* const AccessibilityManager::SIGNAL_ACTION_OVER( "accessibility-action-over" );
+const char* const AccessibilityManager::SIGNAL_ACTION_READ( "accessibility-action-read" );
+const char* const AccessibilityManager::SIGNAL_ACTION_READ_NEXT( "accessibility-action-read-next" );
+const char* const AccessibilityManager::SIGNAL_ACTION_READ_PREVIOUS( "accessibility-action-read-previous" );
+const char* const AccessibilityManager::SIGNAL_ACTION_UP( "accessibility-action-up" );
+const char* const AccessibilityManager::SIGNAL_ACTION_DOWN( "accessibility-action-down" );
+const char* const AccessibilityManager::SIGNAL_ACTION_CLEAR_FOCUS( "accessibility-action-clear-focus" );
+const char* const AccessibilityManager::SIGNAL_ACTION_BACK( "accessibility-action-back" );
+const char* const AccessibilityManager::SIGNAL_ACTION_SCROLL( "accessibility-action-scroll" );
+
+AccessibilityManager::AccessibilityManager()
+{
+}
+
+AccessibilityManager AccessibilityManager::Get()
+{
+ return Internal::Adaptor::AccessibilityManager::Get();
+}
+
+AccessibilityManager::~AccessibilityManager()
+{
+}
+
+Vector2 AccessibilityManager::GetReadPosition() const
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).GetReadPosition();
+}
+
+bool AccessibilityManager::IsEnabled() const
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).IsEnabled();
+}
+
+void AccessibilityManager::SetActionHandler(AccessibilityActionHandler& handler)
+{
+ Internal::Adaptor::AccessibilityManager::GetImplementation(*this).SetActionHandler(handler);
+}
+
+void AccessibilityManager::SetGestureHandler(AccessibilityGestureHandler& handler)
+{
+ Internal::Adaptor::AccessibilityManager::GetImplementation(*this).SetGestureHandler(handler);
+}
+
+bool AccessibilityManager::HandleActionNextEvent(bool allowEndFeedback)
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionNextEvent(allowEndFeedback);
+}
+
+bool AccessibilityManager::HandleActionPreviousEvent(bool allowEndFeedback)
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionPreviousEvent(allowEndFeedback);
+}
+
+bool AccessibilityManager::HandleActionActivateEvent()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionActivateEvent();
+}
+
+bool AccessibilityManager::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionReadEvent(x, y, allowReadAgain);
+}
+
+bool AccessibilityManager::HandleActionReadNextEvent(bool allowEndFeedback)
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionReadNextEvent(allowEndFeedback);
+}
+
+bool AccessibilityManager::HandleActionReadPreviousEvent(bool allowEndFeedback)
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionReadPreviousEvent(allowEndFeedback);
+}
+
+bool AccessibilityManager::HandleActionUpEvent()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionUpEvent();
+}
+
+bool AccessibilityManager::HandleActionDownEvent()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionDownEvent();
+}
+
+bool AccessibilityManager::HandleActionClearFocusEvent()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionClearFocusEvent();
+}
+
+bool AccessibilityManager::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp);
+}
+
+bool AccessibilityManager::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionTouchEvent(point, timeStamp);
+}
+
+bool AccessibilityManager::HandleActionBackEvent()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionBackEvent();
+}
+
+void AccessibilityManager::HandleActionEnableEvent()
+{
+ Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionEnableEvent();
+}
+
+void AccessibilityManager::HandleActionDisableEvent()
+{
+ Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionDisableEvent();
+}
+
+AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::StatusChangedSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).StatusChangedSignal();
+}
+
+AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionNextSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionNextSignal();
+}
+
+AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionPreviousSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionPreviousSignal();
+}
+
+AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionActivateSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionActivateSignal();
+}
+
+AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionOverSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionOverSignal();
+}
+
+AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionReadSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionReadSignal();
+}
+
+AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionReadNextSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionReadNextSignal();
+}
+
+AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionReadPreviousSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionReadPreviousSignal();
+}
+
+AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionUpSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionUpSignal();
+}
+
+AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionDownSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionDownSignal();
+}
+
+AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionClearFocusSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionClearFocusSignal();
+}
+
+AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionBackSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionBackSignal();
+}
+
+AccessibilityManager::AccessibilityActionScrollSignalV2& AccessibilityManager::ActionScrollSignal()
+{
+ return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionScrollSignal();
+}
+
+AccessibilityManager::AccessibilityManager( Internal::Adaptor::AccessibilityManager& manager )
+: BaseHandle( &manager )
+{
+}
+
+AccessibilityManager::AccessibilityManager( Internal::Adaptor::AccessibilityManager* manager )
+: BaseHandle( manager )
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "adaptor-impl.h"
+
+// EXTERNAL INCLUDES
+#include <boost/thread/tss.hpp>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/core.h>
+#include <dali/integration-api/profiling.h>
+#include <dali/integration-api/input-options.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+
+// INTERNAL INCLUDES
+#include <base/update-render-controller.h>
+#include <base/environment-variables.h>
+#include <base/performance-logging/performance-interface-factory.h>
+#include <base/lifecycle-observer.h>
+
+#include <callback-manager.h>
+#include <trigger-event.h>
+#include <render-surface-impl.h>
+#include <tts-player-impl.h>
+#include <accessibility-manager-impl.h>
+#include <timer-impl.h>
+#include <events/gesture-manager.h>
+#include <events/event-handler.h>
+#include <feedback/feedback-controller.h>
+#include <feedback/feedback-plugin-proxy.h>
+#include <gl/gl-proxy-implementation.h>
+#include <gl/gl-implementation.h>
+#include <gl/egl-sync-implementation.h>
+#include <gl/egl-image-extensions.h>
+#include <gl/egl-factory.h>
+#include <imf-manager-impl.h>
+#include <clipboard-impl.h>
+#include <vsync-monitor.h>
+#include <object-profiler.h>
+
+#include <slp-logging.h>
+
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+boost::thread_specific_ptr<Adaptor> gThreadLocalAdaptor;
+
+unsigned int GetIntegerEnvironmentVariable( const char* variable, unsigned int defaultValue )
+{
+ const char* variableParameter = std::getenv(variable);
+
+ // if the parameter exists convert it to an integer, else return the default value
+ unsigned int intValue = variableParameter ? atoi(variableParameter) : defaultValue;
+ return intValue;
+}
+
+bool GetIntegerEnvironmentVariable( const char* variable, int& intValue )
+{
+ const char* variableParameter = std::getenv(variable);
+
+ if( !variableParameter )
+ {
+ return false;
+ }
+ // if the parameter exists convert it to an integer, else return the default value
+ intValue = atoi(variableParameter);
+ return true;
+}
+
+bool GetBooleanEnvironmentVariable( const char* variable, bool& boolValue )
+{
+ const char* variableParameter = std::getenv(variable);
+
+ boolValue = variableParameter ? true : false;
+ return boolValue;
+}
+
+bool GetFloatEnvironmentVariable( const char* variable, float& floatValue )
+{
+ const char* variableParameter = std::getenv(variable);
+
+ if( !variableParameter )
+ {
+ return false;
+ }
+ // if the parameter exists convert it to an integer, else return the default value
+ floatValue = atof(variableParameter);
+ return true;
+}
+
+} // unnamed namespace
+
+Dali::Adaptor* Adaptor::New( RenderSurface *surface, const DeviceLayout& baseLayout )
+{
+ DALI_ASSERT_ALWAYS( surface->GetType() != Dali::RenderSurface::NO_SURFACE && "No surface for adaptor" );
+
+ Dali::Adaptor* adaptor = new Dali::Adaptor;
+ Adaptor* impl = new Adaptor( *adaptor, surface, baseLayout );
+ adaptor->mImpl = impl;
+
+ impl->Initialize();
+
+ return adaptor;
+}
+
+void Adaptor::ParseEnvironmentOptions()
+{
+ // get logging options
+ unsigned int logFrameRateFrequency = GetIntegerEnvironmentVariable( DALI_ENV_FPS_TRACKING, 0 );
+ unsigned int logupdateStatusFrequency = GetIntegerEnvironmentVariable( DALI_ENV_UPDATE_STATUS_INTERVAL, 0 );
+ unsigned int logPerformanceLevel = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE, 0 );
+ unsigned int logPanGesture = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PAN_GESTURE, 0 );
+
+ // all threads here (event, update, and render) will send their logs to SLP Platform's LogMessage handler.
+ Dali::Integration::Log::LogFunction logFunction(Dali::SlpPlatform::LogMessage);
+
+ mEnvironmentOptions.SetLogOptions( logFunction, logFrameRateFrequency, logupdateStatusFrequency, logPerformanceLevel, logPanGesture );
+
+ int predictionMode;
+ if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_MODE, predictionMode) )
+ {
+ mEnvironmentOptions.SetPanGesturePredictionMode(predictionMode);
+ }
+ int predictionAmount = -1;
+ if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT, predictionAmount) )
+ {
+ if( predictionAmount < 0 )
+ {
+ // do not support times in the past
+ predictionAmount = 0;
+ }
+ mEnvironmentOptions.SetPanGesturePredictionAmount(predictionAmount);
+ }
+ int smoothingMode;
+ if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_MODE, smoothingMode) )
+ {
+ mEnvironmentOptions.SetPanGestureSmoothingMode(smoothingMode);
+ }
+ float smoothingAmount = 1.0f;
+ if( GetFloatEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_AMOUNT, smoothingAmount) )
+ {
+ smoothingAmount = Clamp(smoothingAmount, 0.0f, 1.0f);
+ mEnvironmentOptions.SetPanGestureSmoothingAmount(smoothingAmount);
+ }
+
+ int minimumDistance(-1);
+ if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_DISTANCE, minimumDistance ))
+ {
+ mEnvironmentOptions.SetMinimumPanDistance( minimumDistance );
+ }
+
+ int minimumEvents(-1);
+ if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_EVENTS, minimumEvents ))
+ {
+ mEnvironmentOptions.SetMinimumPanEvents( minimumEvents );
+ }
+
+ int glesCallTime(0);
+ if ( GetIntegerEnvironmentVariable(DALI_GLES_CALL_TIME, glesCallTime ))
+ {
+ mEnvironmentOptions.SetGlesCallTime( glesCallTime );
+ }
+
+ mEnvironmentOptions.InstallLogFunction();
+}
+
+void Adaptor::Initialize()
+{
+ ParseEnvironmentOptions();
+
+ mPlatformAbstraction = new SlpPlatform::SlpPlatformAbstraction;
+
+ if( mEnvironmentOptions.GetPerformanceLoggingLevel() > 0 )
+ {
+ mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, mEnvironmentOptions );
+ }
+
+ mCallbackManager = CallbackManager::New();
+
+ PositionSize size = mSurface->GetPositionSize();
+
+ mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, mEnvironmentOptions);
+
+ if( mEnvironmentOptions.GetGlesCallTime() > 0 )
+ {
+ mGLES = new GlProxyImplementation( mEnvironmentOptions );
+ }
+ else
+ {
+ mGLES = new GlImplementation();
+ }
+
+ mEglFactory = new EglFactory();
+
+ EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
+
+ mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGLES, *eglSyncImpl, *mGestureManager );
+
+ mObjectProfiler = new ObjectProfiler();
+
+ mNotificationTrigger = new TriggerEvent( boost::bind(&Adaptor::ProcessCoreEvents, this) );
+
+ mVSyncMonitor = new VSyncMonitor;
+
+ mUpdateRenderController = new UpdateRenderController( *this, mEnvironmentOptions );
+
+ mDaliFeedbackPlugin = new FeedbackPluginProxy( FeedbackPluginProxy::DEFAULT_OBJECT_NAME );
+
+ // Should be called after Core creation
+ if( mEnvironmentOptions.GetPanGestureLoggingLevel() )
+ {
+ Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
+ }
+ if( mEnvironmentOptions.GetPanGesturePredictionMode() >= 0 )
+ {
+ Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGesturePredictionMode());
+ }
+ if( mEnvironmentOptions.GetPanGesturePredictionAmount() >= 0.0f )
+ {
+ Integration::SetPanGesturePredictionAmount(mEnvironmentOptions.GetPanGesturePredictionAmount());
+ }
+ if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 )
+ {
+ Integration::SetPanGestureSmoothingMode(mEnvironmentOptions.GetPanGestureSmoothingMode());
+ }
+ if( mEnvironmentOptions.GetPanGestureSmoothingAmount() >= 0.0f )
+ {
+ Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions.GetPanGestureSmoothingAmount());
+ }
+}
+
+Adaptor::~Adaptor()
+{
+ // Ensure stop status
+ Stop();
+
+ // Release first as we do not want any access to Adaptor as it is being destroyed.
+ gThreadLocalAdaptor.release();
+
+ for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
+ {
+ (*iter)->OnDestroy();
+ }
+
+ delete mUpdateRenderController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
+ delete mVSyncMonitor;
+ delete mEventHandler;
+ delete mObjectProfiler;
+
+ delete mCore;
+ delete mEglFactory;
+ // Delete feedback controller before feedback plugin & style monitor dependencies
+ delete mFeedbackController;
+ delete mDaliFeedbackPlugin;
+ delete mGLES;
+ delete mGestureManager;
+ delete mPlatformAbstraction;
+ delete mCallbackManager;
+ delete mPerformanceInterface;
+
+ // uninstall it on this thread (main actor thread)
+ Dali::Integration::Log::UninstallLogFunction();
+}
+
+void Adaptor::Start()
+{
+ // it doesn't support restart after stop at this moment
+ // to support restarting, need more testing
+ if( READY != mState )
+ {
+ return;
+ }
+
+ // Start the callback manager
+ mCallbackManager->Start();
+
+ // create event handler
+ mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
+
+ if( mDeferredRotationObserver != NULL )
+ {
+ mEventHandler->SetRotationObserver(mDeferredRotationObserver);
+ mDeferredRotationObserver = NULL;
+ }
+
+ // guarantee map the surface before starting render-thread.
+ mSurface->Map();
+
+ // NOTE: dpi must be set before starting the render thread
+ // use default or command line settings if not run on device
+#ifdef __arm__
+ // set the DPI value for font rendering
+ unsigned int dpiHor, dpiVer;
+ dpiHor = dpiVer = 0;
+ mSurface->GetDpi(dpiHor, dpiVer);
+
+ // tell core about the value
+ mCore->SetDpi(dpiHor, dpiVer);
+#else
+ mCore->SetDpi(mHDpi, mVDpi);
+#endif
+
+ // Tell the core the size of the surface just before we start the render-thread
+ PositionSize size = mSurface->GetPositionSize();
+ mCore->SurfaceResized( size.width, size.height );
+
+ // Start the update & render threads
+ mUpdateRenderController->Start();
+
+ mState = RUNNING;
+
+ ProcessCoreEvents(); // Ensure any startup messages are processed.
+
+ if ( !mFeedbackController )
+ {
+ // Start sound & haptic feedback
+ mFeedbackController = new FeedbackController( *mDaliFeedbackPlugin );
+ }
+
+ for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
+ {
+ (*iter)->OnStart();
+ }
+}
+
+// Dali::Internal::Adaptor::Adaptor::Pause
+void Adaptor::Pause()
+{
+ // Only pause the adaptor if we're actually running.
+ if( RUNNING == mState )
+ {
+ // Inform observers that we are about to be paused.
+ for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
+ {
+ (*iter)->OnPause();
+ }
+
+ // Reset the event handler when adaptor paused
+ if( mEventHandler )
+ {
+ mEventHandler->Reset();
+ }
+
+ mUpdateRenderController->Pause();
+ mCore->Suspend();
+ mState = PAUSED;
+ }
+}
+
+// Dali::Internal::Adaptor::Adaptor::Resume
+void Adaptor::Resume()
+{
+ // Only resume the adaptor if we are in the suspended state.
+ if( PAUSED == mState )
+ {
+ mCore->Resume();
+ mUpdateRenderController->Resume();
+ mState = RUNNING;
+
+ // Reset the event handler when adaptor resumed
+ if( mEventHandler )
+ {
+ mEventHandler->Reset();
+ }
+
+ // Inform observers that we have resumed.
+ for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
+ {
+ (*iter)->OnResume();
+ }
+
+ ProcessCoreEvents(); // Ensure any outstanding messages are processed
+ }
+}
+
+void Adaptor::Stop()
+{
+ if( RUNNING == mState ||
+ PAUSED == mState ||
+ PAUSED_WHILE_HIDDEN == mState )
+ {
+ for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
+ {
+ (*iter)->OnStop();
+ }
+
+ mUpdateRenderController->Stop();
+ mCore->Suspend();
+
+ // Delete the TTS player
+ for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
+ {
+ if(mTtsPlayers[i])
+ {
+ mTtsPlayers[i].Reset();
+ }
+ }
+
+ delete mEventHandler;
+ mEventHandler = NULL;
+
+ delete mNotificationTrigger;
+ mNotificationTrigger = NULL;
+
+ mCallbackManager->Stop();
+
+ mState = STOPPED;
+ }
+}
+
+void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
+{
+ mEventHandler->FeedTouchPoint( point, timeStamp );
+}
+
+void Adaptor::FeedWheelEvent( MouseWheelEvent& wheelEvent )
+{
+ mEventHandler->FeedWheelEvent( wheelEvent );
+}
+
+void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
+{
+ mEventHandler->FeedKeyEvent( keyEvent );
+}
+
+bool Adaptor::MoveResize( const PositionSize& positionSize )
+{
+ PositionSize old = mSurface->GetPositionSize();
+
+ // just resize the surface. The driver should automatically resize the egl Surface (untested)
+ // EGL Spec says : EGL window surfaces need to be resized when their corresponding native window
+ // is resized. Implementations typically use hooks into the OS and native window
+ // system to perform this resizing on demand, transparently to the client.
+ mSurface->MoveResize( positionSize );
+
+ if(old.width != positionSize.width || old.height != positionSize.height)
+ {
+ SurfaceSizeChanged(positionSize);
+ }
+
+ return true;
+}
+
+void Adaptor::SurfaceResized( const PositionSize& positionSize )
+{
+ PositionSize old = mSurface->GetPositionSize();
+
+ // Called by an application, when it has resized a window outside of Dali.
+ // The EGL driver automatically detects X Window resize calls, and resizes
+ // the EGL surface for us.
+ mSurface->MoveResize( positionSize );
+
+ if(old.width != positionSize.width || old.height != positionSize.height)
+ {
+ SurfaceSizeChanged(positionSize);
+ }
+}
+
+void Adaptor::ReplaceSurface( Dali::RenderSurface& surface )
+{
+ // adaptor implementation needs the implementation of
+ RenderSurface* internalSurface = dynamic_cast<Internal::Adaptor::RenderSurface*>( &surface );
+ DALI_ASSERT_ALWAYS( internalSurface && "Incorrect surface" );
+
+ mSurface = internalSurface;
+
+ SurfaceSizeChanged( internalSurface->GetPositionSize() );
+
+ // flush the event queue to give update and render threads chance
+ // to start processing messages for new camera setup etc as soon as possible
+ ProcessCoreEvents();
+
+ // this method is synchronous
+ mUpdateRenderController->ReplaceSurface(internalSurface);
+}
+
+void Adaptor::RenderSync()
+{
+ mUpdateRenderController->RenderSync();
+}
+
+Dali::RenderSurface& Adaptor::GetSurface() const
+{
+ return *mSurface;
+}
+
+Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
+{
+ if(!mTtsPlayers[mode])
+ {
+ // Create the TTS player when it needed, because it can reduce launching time.
+ mTtsPlayers[mode] = TtsPlayer::New(mode);
+ }
+
+ return mTtsPlayers[mode];
+}
+
+bool Adaptor::AddIdle(boost::function<void(void)> callBack)
+{
+ bool idleAdded(false);
+
+ // Only add an idle if the Adaptor is actually running
+ if( RUNNING == mState )
+ {
+ idleAdded = mCallbackManager->AddCallback(callBack, CallbackManager::IDLE_PRIORITY);
+ }
+
+ return idleAdded;
+}
+
+bool Adaptor::CallFromMainLoop(boost::function<void(void)> callBack)
+{
+ bool callAdded(false);
+
+ // Only allow the callback if the Adaptor is actually running
+ if ( RUNNING == mState )
+ {
+ callAdded = mCallbackManager->AddCallback(callBack, CallbackManager::DEFAULT_PRIORITY);
+ }
+
+ return callAdded;
+}
+
+Dali::Adaptor& Adaptor::Get()
+{
+ DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() != NULL && "Adaptor not instantiated" );
+ return gThreadLocalAdaptor->mAdaptor;
+}
+
+bool Adaptor::IsAvailable()
+{
+ return gThreadLocalAdaptor.get() != NULL;
+}
+
+Dali::Integration::Core& Adaptor::GetCore()
+{
+ return *mCore;
+}
+
+void Adaptor::DisableVSync()
+{
+ mUpdateRenderController->DisableVSync();
+}
+
+void Adaptor::SetDpi(size_t hDpi, size_t vDpi)
+{
+ mHDpi = hDpi;
+ mVDpi = vDpi;
+}
+
+EglFactory& Adaptor::GetEGLFactory() const
+{
+ DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
+ return *mEglFactory;
+}
+
+EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
+{
+ return *mEglFactory;
+}
+
+Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
+{
+ DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
+ return *mGLES;
+}
+
+Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
+{
+ return *mPlatformAbstraction;
+}
+
+Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
+{
+ return *mGLES;
+}
+
+TriggerEventInterface& Adaptor::GetTriggerEventInterface()
+{
+ return *mNotificationTrigger;
+}
+TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
+{
+ return mTriggerEventFactory;
+}
+RenderSurface* Adaptor::GetRenderSurfaceInterface()
+{
+ return mSurface;
+}
+VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
+{
+ return mVSyncMonitor;
+}
+
+KernelTraceInterface& Adaptor::GetKernelTraceInterface()
+{
+ return mKernelTracer;
+}
+
+PerformanceInterface* Adaptor::GetPerformanceInterface()
+{
+ return mPerformanceInterface;
+}
+
+Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
+{
+ DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
+ return *mPlatformAbstraction;
+}
+
+void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
+{
+ mDragAndDropDetector = detector;
+
+ if ( mEventHandler )
+ {
+ mEventHandler->SetDragAndDropDetector( detector );
+ }
+}
+
+void Adaptor::SetRotationObserver( RotationObserver* observer )
+{
+ if( mEventHandler )
+ {
+ mEventHandler->SetRotationObserver( observer );
+ }
+ else if( mState == READY )
+ {
+ // Set once event handler exists
+ mDeferredRotationObserver = observer;
+ }
+}
+
+void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
+{
+ if(mTtsPlayers[mode])
+ {
+ mTtsPlayers[mode].Reset();
+ }
+}
+
+void Adaptor::SetMinimumPinchDistance(float distance)
+{
+ if( mGestureManager )
+ {
+ mGestureManager->SetMinimumPinchDistance(distance);
+ }
+}
+
+void Adaptor::AddObserver( LifeCycleObserver& observer )
+{
+ ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
+
+ if ( match == mObservers.end() )
+ {
+ mObservers.push_back( &observer );
+ }
+}
+
+void Adaptor::RemoveObserver( LifeCycleObserver& observer )
+{
+ ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
+
+ if ( match != mObservers.end() )
+ {
+ mObservers.erase( match );
+ }
+}
+
+void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
+{
+ if( mCore )
+ {
+ mCore->QueueEvent(event);
+ }
+}
+
+void Adaptor::ProcessCoreEvents()
+{
+ if( mCore )
+ {
+ if( mPerformanceInterface )
+ {
+ mPerformanceInterface->AddMarker( PerformanceMarker::PROCESS_EVENTS_START );
+ }
+
+ mCore->ProcessEvents();
+
+ if( mPerformanceInterface )
+ {
+ mPerformanceInterface->AddMarker( PerformanceMarker::PROCESS_EVENTS_END );
+ }
+ }
+}
+
+void Adaptor::RequestUpdate()
+{
+ // When Dali applications are partially visible behind the lock-screen,
+ // the indicator must be updated (therefore allow updates in the PAUSED state)
+ if ( PAUSED == mState ||
+ RUNNING == mState )
+ {
+ mUpdateRenderController->RequestUpdate();
+ }
+}
+
+void Adaptor::RequestProcessEventsOnIdle()
+{
+ // Only request a notification if the Adaptor is actually running
+ if ( RUNNING == mState )
+ {
+ boost::unique_lock<boost::mutex> lock( mIdleInstaller );
+
+ // check if the idle handle is already installed
+ if( mNotificationOnIdleInstalled )
+ {
+ return;
+ }
+ mNotificationOnIdleInstalled = AddIdle( boost::bind( &Adaptor::ProcessCoreEventsFromIdle, this ) );
+ }
+}
+
+void Adaptor::OnWindowShown()
+{
+ if ( PAUSED_WHILE_HIDDEN == mState )
+ {
+ // Adaptor can now be resumed
+ mState = PAUSED;
+
+ Resume();
+
+ // Force a render task
+ RequestUpdateOnce();
+ }
+}
+
+void Adaptor::OnWindowHidden()
+{
+ if ( STOPPED != mState )
+ {
+ Pause();
+
+ // Adaptor cannot be resumed until the window is shown
+ mState = PAUSED_WHILE_HIDDEN;
+ }
+}
+
+// Dali::Internal::Adaptor::Adaptor::OnDamaged
+void Adaptor::OnDamaged( const DamageArea& area )
+{
+ // This is needed for the case where Dali window is partially obscured
+ RequestUpdate();
+}
+
+void Adaptor::SurfaceSizeChanged(const PositionSize& positionSize)
+{
+ // let the core know the surface size has changed
+ mCore->SurfaceResized(positionSize.width, positionSize.height);
+
+ mResizedSignalV2.Emit( mAdaptor );
+}
+
+void Adaptor::NotifyLanguageChanged()
+{
+ mLanguageChangedSignalV2.Emit( mAdaptor );
+}
+
+void Adaptor::RequestUpdateOnce()
+{
+ if( PAUSED_WHILE_HIDDEN != mState )
+ {
+ if( mUpdateRenderController )
+ {
+ mUpdateRenderController->RequestUpdateOnce();
+ }
+ }
+}
+
+void Adaptor::ProcessCoreEventsFromIdle()
+{
+ ProcessCoreEvents();
+
+ // the idle handle automatically un-installs itself
+ mNotificationOnIdleInstalled = false;
+}
+
+void Adaptor::RegisterSingleton(const std::type_info& info, BaseHandle singleton)
+{
+ if(singleton)
+ {
+ mSingletonContainer.insert(SingletonPair(info.name(), singleton));
+ }
+}
+
+BaseHandle Adaptor::GetSingleton(const std::type_info& info) const
+{
+ BaseHandle object = Dali::BaseHandle();
+
+ SingletonConstIter iter = mSingletonContainer.find(info.name());
+ if(iter != mSingletonContainer.end())
+ {
+ object = (*iter).second;
+ }
+
+ return object;
+}
+
+Adaptor::Adaptor(Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout)
+: mAdaptor(adaptor),
+ mState(READY),
+ mCore(NULL),
+ mUpdateRenderController(NULL),
+ mVSyncMonitor(NULL),
+ mGLES( NULL ),
+ mEglFactory( NULL ),
+ mSurface( surface ),
+ mPlatformAbstraction( NULL ),
+ mEventHandler( NULL ),
+ mCallbackManager( NULL ),
+ mNotificationOnIdleInstalled( false ),
+ mNotificationTrigger(NULL),
+ mGestureManager(NULL),
+ mHDpi( 0 ),
+ mVDpi( 0 ),
+ mDaliFeedbackPlugin(NULL),
+ mFeedbackController(NULL),
+ mObservers(),
+ mDragAndDropDetector(),
+ mDeferredRotationObserver(NULL),
+ mBaseLayout(baseLayout),
+ mEnvironmentOptions(),
+ mPerformanceInterface(NULL),
+ mObjectProfiler(NULL)
+{
+ DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() == NULL && "Cannot create more than one Adaptor per thread" );
+ gThreadLocalAdaptor.reset(this);
+}
+
+// Stereoscopy
+
+void Adaptor::SetViewMode( ViewMode viewMode )
+{
+ mSurface->SetViewMode( viewMode );
+ mCore->SetViewMode( viewMode );
+}
+
+ViewMode Adaptor::GetViewMode() const
+{
+ return mCore->GetViewMode();
+}
+
+void Adaptor::SetStereoBase( float stereoBase )
+{
+ mCore->SetStereoBase( stereoBase );
+}
+
+float Adaptor::GetStereoBase() const
+{
+ return mCore->GetStereoBase();
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_IMPL_H__
+#define __DALI_INTERNAL_ADAPTOR_IMPL_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/bind.hpp>
+#include <boost/function.hpp>
+#include <boost/thread.hpp>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/common/view-mode.h>
+#include <dali/public-api/math/rect.h>
+#include <dali/integration-api/render-controller.h>
+
+#include <adaptor.h>
+#include <render-surface.h>
+#include <tts-player.h>
+#include <imf-manager.h>
+#include <device-layout.h>
+#include <clipboard.h>
+
+#include <slp-platform-abstraction.h>
+#include <base/interfaces/adaptor-internal-services.h>
+#include <base/environment-options.h>
+#include <base/core-event-interface.h>
+#include <drag-and-drop-detector-impl.h>
+#include <damage-observer.h>
+#include <window-visibility-observer.h>
+#include <kernel-trace.h>
+#include <trigger-event-factory.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+class Core;
+class GlAbstraction;
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class EventHandler;
+class EglFactory;
+class GestureManager;
+class GlImplementation;
+class GlSyncImplementation;
+class RenderSurface;
+class UpdateRenderController;
+class TriggerEvent;
+class CallbackManager;
+class FeedbackPluginProxy;
+class FeedbackController;
+class RotationObserver;
+class VSyncMonitor;
+class PerformanceInterface;
+class LifeCycleObserver;
+class ObjectProfiler;
+
+/**
+ * Implementation of the Adaptor class.
+ */
+class Adaptor : public Integration::RenderController,
+ public AdaptorInternalServices,
+ public CoreEventInterface,
+ public DamageObserver,
+ public WindowVisibilityObserver
+{
+public:
+
+ typedef Dali::Adaptor::AdaptorSignalV2 AdaptorSignalV2;
+
+ typedef std::pair<std::string, BaseHandle> SingletonPair;
+ typedef std::map<std::string, BaseHandle> SingletonContainer;
+ typedef SingletonContainer::const_iterator SingletonConstIter;
+
+ /**
+ * Creates a New Adaptor
+ * @param[in] surface A render surface can be one of the following
+ * - Pixmap, adaptor will use existing Pixmap to draw on to
+ * - Window, adaptor will use existing Window to draw on to
+ * @param[in] baseLayout The base layout that the application has been written for
+ */
+ DALI_IMPORT_API static Dali::Adaptor* New( RenderSurface* surface, const DeviceLayout& baseLayout );
+
+ /**
+ * 2-step initialisation, this should be called after creating an adaptor instance.
+ */
+ void Initialize();
+
+ /**
+ * Virtual destructor.
+ */
+ virtual ~Adaptor();
+
+ /**
+ * @copydoc Dali::Adaptor::Get()
+ */
+ static Dali::Adaptor& Get();
+
+ /**
+ * @copydoc Dali::Adaptor::IsAvailable()
+ */
+ static bool IsAvailable();
+
+public: // AdaptorInternalServices implementation
+ /**
+ * @copydoc Dali::Adaptor::Start()
+ */
+ virtual void Start();
+
+ /**
+ * @copydoc Dali::Adaptor::Pause()
+ */
+ virtual void Pause();
+
+ /**
+ * @copydoc Dali::Adaptor::Resume()
+ */
+ virtual void Resume();
+
+ /**
+ * @copydoc Dali::Adaptor::Stop()
+ */
+ virtual void Stop();
+
+ /**
+ * @copydoc Dali::EventFeeder::FeedTouchPoint()
+ */
+ virtual void FeedTouchPoint( TouchPoint& point, int timeStamp );
+
+ /**
+ * @copydoc Dali::EventFeeder::FeedWheelEvent()
+ */
+ virtual void FeedWheelEvent( MouseWheelEvent& wheelEvent );
+
+ /**
+ * @copydoc Dali::EventFeeder::FeedKeyEvent()
+ */
+ virtual void FeedKeyEvent( KeyEvent& keyEvent );
+
+ /**
+ * @copydoc AdaptorInterface::MoveResize()
+ */
+ virtual bool MoveResize( const PositionSize& positionSize );
+
+ /**
+ * @copydoc AdaptorInterface::SurfaceResized()
+ */
+ virtual void SurfaceResized( const PositionSize& positionSize );
+
+ /**
+ * @copydoc AdaptorInterface::ReplaceSurface()
+ */
+ virtual void ReplaceSurface( Dali::RenderSurface& surface );
+
+ /**
+ * @copydoc AdaptorInterface::RenderSync()
+ */
+ virtual void RenderSync();
+
+ /**
+ * @copydoc Dali::Adaptor::GetSurface()
+ */
+ virtual Dali::RenderSurface& GetSurface() const;
+
+ /**
+ * Retrieve the TtsPlayer.
+ * @param[in] mode The mode of TtsPlayer
+ * @return A handle to the TtsPlayer.
+ */
+ virtual Dali::TtsPlayer GetTtsPlayer(Dali::TtsPlayer::Mode mode);
+
+ /**
+ * @copydoc Dali::Adaptor::AddIdle()
+ */
+ virtual bool AddIdle( boost::function<void(void)> callBack );
+
+ /**
+ * @copydoc Internal::Framework::CallFromMainLoop()
+ */
+ virtual bool CallFromMainLoop(boost::function<void(void)> callBack);
+
+ /**
+ * @copydoc Dali::Adaptor::RegisterSingleton()
+ */
+ virtual void RegisterSingleton(const std::type_info& info, BaseHandle singleton);
+
+ /**
+ * @copydoc Dali::Adaptor::GetSingleton()
+ */
+ virtual BaseHandle GetSingleton(const std::type_info& info) const;
+
+public:
+
+ /**
+ * @return the Core instance
+ */
+ virtual Dali::Integration::Core& GetCore();
+
+ /**
+ * Disables GL draw synchronisation with the display.
+ */
+ DALI_IMPORT_API void DisableVSync();
+
+ /**
+ * Overrides DPI.
+ * Primarily for host/simulation testing
+ * @param[in] hDpi The Horizontal DPI
+ * @param[in] vDpi The Vertical DPI
+ */
+ DALI_IMPORT_API void SetDpi(size_t hDpi, size_t vDpi);
+
+ /**
+ * @return reference to EglFactory class
+ */
+ EglFactory& GetEGLFactory() const;
+
+ /**
+ * Return GlAbstraction.
+ * @return the GlAbstraction.
+ */
+ Integration::GlAbstraction& GetGlAbstraction() const;
+
+ /**
+ * Return the PlatformAbstraction.
+ * @return The PlatformAbstraction.
+ */
+ Integration::PlatformAbstraction& GetPlatformAbstraction() const;
+
+ /**
+ * Sets the Drag & Drop Listener.
+ * @param[in] detector The detector to send Drag & Drop events to.
+ */
+ void SetDragAndDropDetector( DragAndDropDetectorPtr detector );
+
+ /**
+ * Sets a rotation observer, or set to NULL to remove.
+ * @pre Adaptor::Start() has been called ( to create EventHandler )
+ * @param[in] observer The observer to listen for window rotation events
+ */
+ void SetRotationObserver( RotationObserver* observer );
+
+ /**
+ * Destroy the TtsPlayer of sepcific mode.
+ * @param[in] mode The mode of TtsPlayer to destroy
+ */
+ void DestroyTtsPlayer(Dali::TtsPlayer::Mode mode);
+
+ /**
+ * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to
+ * trigger a pinch gesture
+ *
+ * @param[in] distance The minimum pinch distance in pixels
+ */
+ void SetMinimumPinchDistance(float distance);
+
+public:
+
+ /**
+ * Adds an adaptor observer so that we can observe the adaptor's lifetime events.
+ * @param[in] observer The observer.
+ * @note Observers should remove themselves when they are destroyed.
+ */
+ void AddObserver( LifeCycleObserver& observer );
+
+ /**
+ * Removes the observer from the adaptor.
+ * @param[in] observer The observer to remove.
+ * @note Observers should remove themselves when they are destroyed.
+ */
+ void RemoveObserver( LifeCycleObserver& observer );
+
+ /**
+ * Emits the Notification event to the Dali core.
+ */
+ void SendNotificationEvent();
+
+ /**
+ * Request adaptor to update once
+ */
+ void RequestUpdateOnce();
+
+ /**
+ * @copydoc Dali::Adaptor::NotifyLanguageChanged()
+ */
+ void NotifyLanguageChanged();
+
+public: //AdaptorInternalServices
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetPlatformAbstractionInterface()
+ */
+ virtual Dali::Integration::PlatformAbstraction& GetPlatformAbstractionInterface();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetGlesInterface()
+ */
+ virtual Dali::Integration::GlAbstraction& GetGlesInterface();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetEGLFactoryInterface()
+ */
+ virtual EglFactoryInterface& GetEGLFactoryInterface() const;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventInterface()
+ */
+ virtual TriggerEventInterface& GetTriggerEventInterface();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventFactoryInterface()
+ */
+ virtual TriggerEventFactoryInterface& GetTriggerEventFactoryInterface();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetRenderSurfaceInterface()
+ */
+ virtual RenderSurface* GetRenderSurfaceInterface();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetVSyncMonitorInterface()
+ */
+ virtual VSyncMonitorInterface* GetVSyncMonitorInterface();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetPerformanceInterface()
+ */
+ virtual PerformanceInterface* GetPerformanceInterface();
+
+ /**
+ * copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetKernelTraceInterface()
+ */
+ virtual KernelTraceInterface& GetKernelTraceInterface();
+
+public: // Stereoscopy
+
+ /**
+ * @copydoc Dali::Integration::Core::SetViewMode()
+ */
+ DALI_IMPORT_API void SetViewMode( ViewMode viewMode );
+
+ /**
+ * @copydoc Dali::Integration::Core::GetViewMode()
+ */
+ DALI_IMPORT_API ViewMode GetViewMode() const;
+
+ /**
+ * @copydoc Dali::Integration::Core::SetStereoBase()
+ */
+ DALI_IMPORT_API void SetStereoBase( float stereoBase );
+
+ /**
+ * @copydoc Dali::Integration::Core::GetStereoBase()
+ */
+ DALI_IMPORT_API float GetStereoBase() const;
+
+public: // Signals
+
+ /**
+ * @copydoc Dali::Adaptor::SignalResized
+ */
+ AdaptorSignalV2& ResizedSignal()
+ {
+ return mResizedSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::Adaptor::LanguageChangedSignal
+ */
+ AdaptorSignalV2& LanguageChangedSignal()
+ {
+ return mLanguageChangedSignalV2;
+ }
+
+private: // From Dali::Internal::Adaptor::CoreEventInterface
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::CoreEventInterface::QueueCoreEvent()
+ */
+ virtual void QueueCoreEvent(const Dali::Integration::Event& event);
+
+ /**
+ * @copydoc Dali::Internal::Adaptor:CoreEventInterface:::ProcessCoreEvents()
+ */
+ virtual void ProcessCoreEvents();
+
+private: // From Dali::Integration::RenderController
+
+ /**
+ * Called by the Dali core when it requires another update
+ */
+ virtual void RequestUpdate();
+
+ /**
+ * Call by the Dali core when it requires an notification event being sent on idle
+ */
+ virtual void RequestProcessEventsOnIdle();
+
+private: // From Dali::Internal::Adaptor::WindowVisibilityObserver
+
+ /**
+ * Called when the window becomes fully or partially visible.
+ */
+ virtual void OnWindowShown();
+
+ /**
+ * Called when the window is fully hidden.
+ */
+ virtual void OnWindowHidden();
+
+private: // From Dali::Internal::Adaptor::DamageObserver
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::DamageObserver::OnDamaged()
+ */
+ void OnDamaged( const DamageArea& area );
+
+private:
+
+ // Undefined
+ Adaptor(const Adaptor&);
+ Adaptor& operator=(Adaptor&);
+
+private:
+
+ /**
+ * Helper to parse log options
+ */
+ void ParseEnvironmentOptions();
+
+ /**
+ * Informs core the surface size has changed
+ */
+ void SurfaceSizeChanged(const PositionSize& positionSize);
+
+ /**
+ * Assigns the render surface to the adaptor
+ *
+ */
+ void SetSurface(Dali::RenderSurface *surface);
+
+ /**
+ * Sends an notification message from main loop idle handler
+ */
+ void ProcessCoreEventsFromIdle();
+
+private:
+
+ /**
+ * Constructor
+ * @param[in] adaptor The public adaptor
+ * @param[in] surface A render surface can be one of the following
+ * - Pixmap, adaptor will use existing Pixmap to draw on to
+ * - Window, adaptor will use existing Window to draw on to
+ * @param[in] baseLayout The base layout that the application has been written for
+ */
+ Adaptor( Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout );
+
+private: // Types
+
+ enum State
+ {
+ READY, ///< Initial state before Adaptor::Start is called.
+ RUNNING, ///< Adaptor is running.
+ PAUSED, ///< Adaptor has been paused.
+ PAUSED_WHILE_HIDDEN, ///< Adaptor is paused while window is hidden (& cannot be resumed until window is shown).
+ STOPPED, ///< Adaptor has been stopped.
+ };
+
+ typedef std::vector<LifeCycleObserver*> ObserverContainer;
+
+private: // Data
+
+ AdaptorSignalV2 mResizedSignalV2; ///< Resized signal.
+ AdaptorSignalV2 mLanguageChangedSignalV2; ///< Language changed signal.
+
+ Dali::Adaptor& mAdaptor; ///< Reference to public adaptor instance.
+ State mState; ///< Current state of the adaptor
+ Dali::Integration::Core* mCore; ///< Dali Core
+ UpdateRenderController* mUpdateRenderController; ///< Controls update/render threads
+ VSyncMonitor* mVSyncMonitor; ///< Monitors VSync events
+ GlImplementation* mGLES; ///< GL implementation
+ GlSyncImplementation* mGlSync; ///< GL Sync implementation
+ EglFactory* mEglFactory; ///< EGL Factory
+
+ RenderSurface* mSurface; ///< Current surface
+ SlpPlatform::SlpPlatformAbstraction* mPlatformAbstraction; ///< Platform abstraction
+
+ EventHandler* mEventHandler; ///< event handler
+ CallbackManager* mCallbackManager; ///< Used to install callbacks
+ bool mNotificationOnIdleInstalled; ///< whether the idle handler is installed to send an notification event
+ TriggerEvent* mNotificationTrigger; ///< Notification event trigger
+ GestureManager* mGestureManager; ///< Gesture manager
+ boost::mutex mIdleInstaller; ///< mutex to ensure two threads don't try to install idle handler at the same time
+ size_t mHDpi; ///< Override horizontal DPI
+ size_t mVDpi; ///< Override vertical DPI
+ FeedbackPluginProxy* mDaliFeedbackPlugin; ///< Used to access feedback support
+ FeedbackController* mFeedbackController; ///< Plays feedback effects for Dali-Toolkit UI Controls.
+ SingletonContainer mSingletonContainer; ///< The container to look up singleton by its type name
+ Dali::TtsPlayer mTtsPlayers[Dali::TtsPlayer::MODE_NUM]; ///< Provides TTS support
+ ObserverContainer mObservers; ///< A list of adaptor observer pointers
+ DragAndDropDetectorPtr mDragAndDropDetector; ///< The Drag & Drop detector
+ RotationObserver* mDeferredRotationObserver; ///< deferred Rotation observer needs event handler
+ DeviceLayout mBaseLayout; ///< The base layout of the application
+ EnvironmentOptions mEnvironmentOptions; ///< environment options
+ PerformanceInterface* mPerformanceInterface; ///< Performance interface
+ KernelTrace mKernelTracer; ///< Kernel tracer
+ TriggerEventFactory mTriggerEventFactory; ///< Trigger event factory
+ ObjectProfiler* mObjectProfiler; ///< Tracks object lifetime for profiling
+public:
+ inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) {return *adaptor.mImpl;}
+};
+
+} // namespace Internal
+
+} // namespace Adaptor
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ADAPTOR_IMPL_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <adaptor.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <accessibility-manager.h>
+#include <imf-manager.h>
+#include <style-monitor.h>
+#include <window.h>
+
+// INTERNAL INCLUDES
+#include <adaptor-impl.h>
+#include <render-surface-impl.h>
+#include <window-impl.h>
+
+namespace Dali
+{
+
+Adaptor& Adaptor::New( Window window )
+{
+ return New( window, DeviceLayout::DEFAULT_BASE_LAYOUT );
+}
+
+Adaptor& Adaptor::New( Window window, const DeviceLayout& baseLayout )
+{
+ Internal::Adaptor::Window& windowImpl = GetImplementation(window);
+ Adaptor* adaptor = Internal::Adaptor::Adaptor::New( windowImpl.GetSurface(), baseLayout );
+ windowImpl.SetAdaptor(*adaptor);
+ return *adaptor;
+}
+
+Adaptor::~Adaptor()
+{
+ delete mImpl;
+}
+
+void Adaptor::Start()
+{
+ mImpl->Start();
+}
+
+void Adaptor::Pause()
+{
+ mImpl->Pause();
+}
+
+void Adaptor::Resume()
+{
+ mImpl->Resume();
+}
+
+void Adaptor::Stop()
+{
+ mImpl->Stop();
+}
+
+bool Adaptor::AddIdle( boost::function<void(void)> callBack )
+{
+ return mImpl->AddIdle(callBack);
+}
+
+Adaptor::AdaptorSignalV2& Adaptor::ResizedSignal()
+{
+ return mImpl->ResizedSignal();
+}
+
+Adaptor::AdaptorSignalV2& Adaptor::LanguageChangedSignal()
+{
+ return mImpl->LanguageChangedSignal();
+}
+
+RenderSurface& Adaptor::GetSurface()
+{
+ return mImpl->GetSurface();
+}
+
+Adaptor& Adaptor::Get()
+{
+ return Internal::Adaptor::Adaptor::Get();
+}
+
+bool Adaptor::IsAvailable()
+{
+ return Internal::Adaptor::Adaptor::IsAvailable();
+}
+
+void Adaptor::RegisterSingleton(const std::type_info& info, BaseHandle singleton)
+{
+ mImpl->RegisterSingleton(info, singleton);
+}
+
+BaseHandle Adaptor::GetSingleton(const std::type_info& info) const
+{
+ return mImpl->GetSingleton(info);
+}
+
+void Adaptor::NotifyLanguageChanged()
+{
+ mImpl->NotifyLanguageChanged();
+}
+
+void Adaptor::SetMinimumPinchDistance(float distance)
+{
+ mImpl->SetMinimumPinchDistance(distance);
+}
+
+Adaptor::Adaptor()
+: mImpl( NULL )
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "application-impl.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <style-monitor.h>
+
+// INTERNAL INCLUDES
+#include <command-line-options.h>
+#include <common/adaptor-impl.h>
+
+namespace Dali
+{
+
+namespace SlpPlatform
+{
+class SlpPlatformAbstraction;
+}
+
+namespace Integration
+{
+class Core;
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+// Defaults taken from H2 device
+const unsigned int DEFAULT_WINDOW_WIDTH = 480;
+const unsigned int DEFAULT_WINDOW_HEIGHT = 800;
+const float DEFAULT_HORIZONTAL_DPI = 220;
+const float DEFAULT_VERTICAL_DPI = 217;
+
+boost::thread_specific_ptr<Application> gThreadLocalApplication;
+}
+
+ApplicationPtr Application::New(
+ int* argc,
+ char **argv[],
+ const std::string& name,
+ const DeviceLayout& baseLayout,
+ Dali::Application::WINDOW_MODE windowMode)
+{
+ ApplicationPtr application ( new Application (argc, argv, name, baseLayout, windowMode ) );
+ return application;
+}
+
+Application::Application(
+ int* argc,
+ char** argv[],
+ const std::string& name,
+ const DeviceLayout& baseLayout,
+ Dali::Application::WINDOW_MODE windowMode)
+: mFramework(NULL),
+ mCommandLineOptions(NULL),
+ mAdaptor(NULL),
+ mWindow(),
+ mWindowMode( windowMode ),
+ mName(name),
+ mInitialized(false),
+ mBaseLayout(baseLayout),
+ mSlotDelegate( this )
+{
+ // make sure we don't create the local thread application instance twice
+ DALI_ASSERT_ALWAYS(gThreadLocalApplication.get() == NULL && "Cannot create more than one Application per thread" );
+
+ // reset is used to store a new value associated with this thread
+ gThreadLocalApplication.reset(this);
+
+ mCommandLineOptions = new CommandLineOptions(argc, argv);
+
+ mFramework = new Framework(*this, argc, argv, name);
+}
+
+Application::~Application()
+{
+ delete mFramework;
+ delete mCommandLineOptions;
+ delete mAdaptor;
+ mWindow.Reset();
+ gThreadLocalApplication.release();
+}
+
+void Application::CreateWindow()
+{
+#ifndef __arm__
+ PositionSize windowPosition(0, 0, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
+#else
+ PositionSize windowPosition(0, 0, 0, 0); // this will use full screen
+#endif
+ if (mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0)
+ {
+ // let the command line options over ride
+ windowPosition = PositionSize(0,0,mCommandLineOptions->stageWidth,mCommandLineOptions->stageHeight);
+ }
+
+ mWindow = Dali::Window::New( windowPosition, mName, mWindowMode == Dali::Application::TRANSPARENT );
+}
+
+void Application::CreateAdaptor()
+{
+ DALI_ASSERT_ALWAYS( mWindow && "Window required to create adaptor" );
+
+ mAdaptor = &Dali::Adaptor::New( mWindow, mBaseLayout);
+
+ // Allow DPI to be overridden from command line.
+ unsigned int hDPI=DEFAULT_HORIZONTAL_DPI;
+ unsigned int vDPI=DEFAULT_VERTICAL_DPI;
+
+ std::string dpiStr = mCommandLineOptions->stageDPI;
+ if(!dpiStr.empty())
+ {
+ sscanf(dpiStr.c_str(), "%ux%u", &hDPI, &vDPI);
+ }
+ Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetDpi(hDPI, vDPI);
+
+ mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize );
+}
+
+void Application::MainLoop()
+{
+ // Run the application
+ mFramework->Run();
+}
+
+void Application::Lower()
+{
+ // Lower the application without quitting it.
+ mWindow.Lower();
+}
+
+void Application::Quit()
+{
+ // Actually quit the application.
+ AddIdle(boost::bind(&Application::QuitFromMainLoop, this));
+}
+
+void Application::QuitFromMainLoop()
+{
+ mAdaptor->Stop();
+
+ Dali::Application application(this);
+ mTerminateSignalV2.Emit( application );
+
+ mFramework->Quit();
+ // This will trigger OnTerminate(), below, after the main loop has completed.
+ mInitialized = false;
+}
+
+void Application::OnInit()
+{
+ mFramework->AddAbortCallback(boost::bind(&Application::QuitFromMainLoop, this));
+
+ CreateWindow();
+ CreateAdaptor();
+
+ // Run the adaptor
+ mAdaptor->Start();
+
+ // Check if user requires no vsyncing and set on X11 Adaptor
+ if (mCommandLineOptions->noVSyncOnRender)
+ {
+ Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).DisableVSync();
+ }
+
+ Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetStereoBase( mCommandLineOptions->stereoBase );
+ if( mCommandLineOptions->viewMode != 0 )
+ {
+ ViewMode viewMode = MONO;
+ if( mCommandLineOptions->viewMode <= STEREO_INTERLACED )
+ {
+ viewMode = static_cast<ViewMode>( mCommandLineOptions->viewMode );
+ }
+ Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetViewMode( viewMode );
+ }
+
+ mInitialized = true;
+
+ // in default, auto hide indicator mode
+ mWindow.ShowIndicator(Dali::Window::AUTO);
+
+ Dali::Application application(this);
+ mInitSignalV2.Emit( application );
+}
+
+void Application::OnTerminate()
+{
+ // we've been told to quit by AppCore, ecore_x_destroy has been called, need to quit synchronously
+ // delete the window as ecore_x has been destroyed by AppCore
+
+ mWindow.Reset();
+ mInitialized = false;
+}
+
+void Application::OnPause()
+{
+ mAdaptor->Pause();
+ Dali::Application application(this);
+ mPauseSignalV2.Emit( application );
+}
+
+void Application::OnResume()
+{
+ mAdaptor->Resume();
+ Dali::Application application(this);
+ mResumeSignalV2.Emit( application );
+}
+
+void Application::OnReset()
+{
+ /*
+ * usually, reset callback was called when a caller request to launch this application via aul.
+ * because Application class already handled initialization in OnInit(), OnReset do nothing.
+ */
+ Dali::Application application(this);
+ mResetSignalV2.Emit( application );
+
+ mWindow.Raise();
+}
+
+void Application::OnLanguageChanged()
+{
+ mAdaptor->NotifyLanguageChanged();
+}
+
+void Application::OnResize(Dali::Adaptor& adaptor)
+{
+ Dali::Application application(this);
+ mResizeSignalV2.Emit( application );
+}
+
+bool Application::AddIdle(boost::function<void(void)> callBack)
+{
+ return mAdaptor->AddIdle(callBack);
+}
+
+Dali::Adaptor& Application::GetAdaptor()
+{
+ return *mAdaptor;
+}
+
+Dali::Window Application::GetWindow()
+{
+ return mWindow;
+}
+
+Dali::Application Application::Get()
+{
+ DALI_ASSERT_ALWAYS( gThreadLocalApplication.get() != NULL && "Application not instantiated" );
+
+ Dali::Application application(gThreadLocalApplication.get());
+
+ return application;
+}
+
+const std::string& Application::GetTheme()
+{
+ return Dali::StyleMonitor::Get().GetTheme();
+}
+
+void Application::SetTheme(const std::string& themeFilePath)
+{
+ return Dali::StyleMonitor::Get().SetTheme(themeFilePath);
+}
+
+// Stereoscopy
+
+void Application::SetViewMode( ViewMode viewMode )
+{
+ Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetViewMode( viewMode );
+}
+
+ViewMode Application::GetViewMode() const
+{
+ return Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).GetViewMode();
+}
+
+void Application::SetStereoBase( float stereoBase )
+{
+ Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetStereoBase( stereoBase );
+}
+
+float Application::GetStereoBase() const
+{
+ return Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).GetStereoBase();
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_APPLICATION_H__
+#define __DALI_INTERNAL_APPLICATION_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/bind.hpp>
+#include <boost/function.hpp>
+#include <boost/thread.hpp>
+
+#include <dali/public-api/math/rect.h>
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <application.h>
+
+#include <framework.h>
+#include <window-impl.h>
+
+namespace Dali
+{
+class Window;
+class Adaptor;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class CommandLineOptions;
+class EventLoop;
+
+typedef Dali::Rect<int> PositionSize;
+
+class Application;
+typedef IntrusivePtr<Application> ApplicationPtr;
+
+/**
+ * Implementation of the Application class.
+ */
+class Application : public BaseObject, public Framework::Observer
+{
+public:
+
+ typedef Dali::Application::AppSignalV2 AppSignalV2;
+
+ /**
+ * Constructor
+ * @param[in] app The public instance of the Application
+ * @param[in] argc A pointer to the number of arguments
+ * @param[in] argv A pointer to the argument list
+ * @param[in] name A name of application
+ * @param[in] baseLayout The base layout that the application has been written for
+ * @param[in] windowMode A member of Dali::Application::WINDOW_MODE
+ */
+ static ApplicationPtr New(int* argc, char **argv[], const std::string& name,
+ const DeviceLayout& baseLayout,
+ Dali::Application::WINDOW_MODE windowMode);
+
+ Application(int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout, Dali::Application::WINDOW_MODE windowMode );
+
+ /**
+ * Destructor
+ */
+ virtual ~Application();
+
+public:
+
+ /**
+ * @copydoc Dali::Application::MainLoop()
+ */
+ void MainLoop();
+
+ /**
+ * @copydoc Dali::Application::Lower()
+ */
+ void Lower();
+
+ /**
+ * @copydoc Dali::Application::Quit()
+ */
+ void Quit();
+
+ /**
+ * @copydoc Dali::Application::AddIdle()
+ */
+ bool AddIdle(boost::function<void(void)> callBack);
+
+ /**
+ * @copydoc Dali::Application::GetAdaptor();
+ */
+ Dali::Adaptor& GetAdaptor();
+
+ /**
+ * @copydoc Dali::Application::GetWindow();
+ */
+ Dali::Window GetWindow();
+
+ /**
+ * @copydoc Dali::Application::Get();
+ */
+ static Dali::Application Get();
+
+ /**
+ * @copydoc Dali::Application::GetTheme();
+ */
+ const std::string& GetTheme();
+
+ /**
+ * @copydoc Dali::Application::SetTheme();
+ */
+ void SetTheme(const std::string& themeFilePath);
+
+public: // Stereoscopy
+
+ /**
+ * @copydoc Dali::Application::SetViewMode()
+ */
+ void SetViewMode( ViewMode viewMode );
+
+ /**
+ * @copydoc Dali::Application::GetViewMode()
+ */
+ ViewMode GetViewMode() const;
+
+ /**
+ * @copydoc Dali::Application::SetStereoBase()
+ */
+ void SetStereoBase( float stereoBase );
+
+ /**
+ * @copydoc Dali::Application::GetStereoBase()
+ */
+ float GetStereoBase() const;
+
+public: // From Framework::Observer
+
+ /**
+ * Called when the framework is initialised.
+ */
+ virtual void OnInit();
+
+ /**
+ * Called when the framework is terminated.
+ */
+ virtual void OnTerminate();
+
+ /**
+ * Called when the framework is paused.
+ */
+ virtual void OnPause();
+
+ /**
+ * Called when the framework resumes from a paused state.
+ */
+ virtual void OnResume();
+
+ /**
+ * Called when the framework informs the application that it should reset itself.
+ */
+ virtual void OnReset();
+
+ /**
+ * Called when the framework informs the application that the language of the device has changed.
+ */
+ virtual void OnLanguageChanged();
+
+public:
+
+ /**
+ * Signal handler when the adaptor's window resizes itself.
+ * @param[in] adaptor The adaptor
+ */
+ void OnResize(Dali::Adaptor& adaptor);
+
+public: // Signals
+
+ /**
+ * @copydoc Dali::Application::InitSignal()
+ */
+ Dali::Application::AppSignalV2& InitSignal() { return mInitSignalV2; }
+
+ /**
+ * @copydoc Dali::Application::TerminateSignal()
+ */
+ Dali::Application::AppSignalV2& TerminateSignal() { return mTerminateSignalV2; }
+
+ /**
+ * @copydoc Dali::Application::PauseSignal()
+ */
+ Dali::Application::AppSignalV2& PauseSignal() { return mPauseSignalV2; }
+
+ /**
+ * @copydoc Dali::Application::ResumeSignal()
+ */
+ Dali::Application::AppSignalV2& ResumeSignal() { return mResumeSignalV2; }
+
+ /**
+ * @copydoc Dali::Application::ResetSignal()
+ */
+ Dali::Application::AppSignalV2& ResetSignal() { return mResetSignalV2; }
+
+ /**
+ * @copydoc Dali::Application::ResizeSignal()
+ */
+ Dali::Application::AppSignalV2& ResizeSignal() { return mResizeSignalV2; }
+
+ /**
+ * @copydoc Dali::Application::LanguageChangedSignal()
+ */
+ Dali::Application::AppSignalV2& LanguageChangedSignal() { return mLanguageChangedSignalV2; }
+
+private:
+
+ // Undefined
+ Application(const Application&);
+ Application& operator=(Application&);
+
+private:
+ /**
+ * Creates the window
+ */
+ void CreateWindow();
+
+ /**
+ * Creates the adaptor
+ */
+ void CreateAdaptor();
+
+ /**
+ * Quits from the main loop
+ */
+ void QuitFromMainLoop();
+
+private:
+
+ AppSignalV2 mInitSignalV2;
+ AppSignalV2 mTerminateSignalV2;
+ AppSignalV2 mPauseSignalV2;
+ AppSignalV2 mResumeSignalV2;
+ AppSignalV2 mResetSignalV2;
+ AppSignalV2 mResizeSignalV2;
+ AppSignalV2 mLanguageChangedSignalV2;
+
+ EventLoop* mEventLoop;
+ Framework* mFramework;
+
+ CommandLineOptions* mCommandLineOptions;
+
+ Dali::Adaptor* mAdaptor;
+ Dali::Window mWindow;
+ Dali::Application::WINDOW_MODE mWindowMode;
+ std::string mName;
+
+ bool mInitialized;
+ DeviceLayout mBaseLayout;
+
+ SlotDelegate< Application > mSlotDelegate;
+};
+
+inline Application& GetImplementation(Dali::Application& application)
+{
+ DALI_ASSERT_ALWAYS(application && "application handle is empty");
+
+ BaseObject& handle = application.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::Application&>(handle);
+}
+
+inline const Application& GetImplementation(const Dali::Application& application)
+{
+ DALI_ASSERT_ALWAYS(application && "Timre handle is empty");
+
+ const BaseObject& handle = application.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::Application&>(handle);
+}
+
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_APPLICATION_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "application.h"
+
+// EXTERNAL INCLUDES
+#include <orientation.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <application-impl.h>
+#include <orientation-impl.h>
+
+namespace Dali
+{
+
+Application Application::New( int* argc, char **argv[] )
+{
+ Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, "Dali Application", DeviceLayout::DEFAULT_BASE_LAYOUT, OPAQUE );
+ return Application(internal.Get());
+}
+
+Application Application::New( int* argc, char **argv[], const std::string& name )
+{
+ Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, name, DeviceLayout::DEFAULT_BASE_LAYOUT, OPAQUE );
+ return Application(internal.Get());
+}
+
+Application Application::New( int* argc, char **argv[], const std::string& name, WINDOW_MODE windowMode )
+{
+ Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, name, DeviceLayout::DEFAULT_BASE_LAYOUT, windowMode );
+ return Application(internal.Get());
+}
+
+Application Application::New(int* argc, char **argv[], const DeviceLayout& baseLayout)
+{
+ Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, "Dali Application", baseLayout, OPAQUE );
+ return Application(internal.Get());
+}
+
+Application Application::New(int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout)
+{
+ Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, name, baseLayout, OPAQUE );
+ return Application(internal.Get());
+}
+
+Application::~Application()
+{
+}
+
+Application::Application(const Application& application)
+: BaseHandle(application)
+{
+}
+
+Application& Application::operator=(const Application& application)
+{
+ if( *this != application )
+ {
+ BaseHandle::operator=( application );
+ }
+ return *this;
+}
+
+void Application::MainLoop()
+{
+ Internal::Adaptor::GetImplementation(*this).MainLoop();
+}
+
+void Application::Lower()
+{
+ Internal::Adaptor::GetImplementation(*this).Lower();
+}
+
+void Application::Quit()
+{
+ Internal::Adaptor::GetImplementation(*this).Quit();
+}
+
+Orientation Application::GetOrientation()
+{
+ Window window = GetWindow();
+ if( window )
+ {
+ return window.GetOrientation();
+ }
+ return Orientation();
+}
+
+bool Application::AddIdle(boost::function<void(void)> callBack)
+{
+ return Internal::Adaptor::GetImplementation(*this).AddIdle(callBack);
+}
+
+Window Application::GetWindow()
+{
+ return Internal::Adaptor::GetImplementation(*this).GetWindow();
+}
+
+Application Application::Get()
+{
+ return Internal::Adaptor::Application::Get();
+}
+
+void Application::SetViewMode( ViewMode viewMode )
+{
+ Internal::Adaptor::GetImplementation(*this).SetViewMode( viewMode );
+}
+
+ViewMode Application::GetViewMode() const
+{
+ return Internal::Adaptor::GetImplementation(*this).GetViewMode();
+}
+
+void Application::SetStereoBase( float stereoBase )
+{
+ Internal::Adaptor::GetImplementation(*this).SetStereoBase( stereoBase );
+}
+
+float Application::GetStereoBase() const
+{
+ return Internal::Adaptor::GetImplementation(*this).GetStereoBase();
+}
+
+Application::AppSignalV2& Application::InitSignal()
+{
+ return Internal::Adaptor::GetImplementation(*this).InitSignal();
+}
+
+Application::AppSignalV2& Application::TerminateSignal()
+{
+ return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
+}
+
+Application::AppSignalV2& Application::PauseSignal()
+{
+ return Internal::Adaptor::GetImplementation(*this).PauseSignal();
+}
+
+Application::AppSignalV2& Application::ResumeSignal()
+{
+ return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
+}
+
+Application::AppSignalV2& Application::ResetSignal()
+{
+ return Internal::Adaptor::GetImplementation(*this).ResetSignal();
+}
+
+Application::AppSignalV2& Application::ResizeSignal()
+{
+ return Internal::Adaptor::GetImplementation(*this).ResizeSignal();
+}
+
+Application::AppSignalV2& Application::LanguageChangedSignal()
+{
+ return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
+}
+
+Application::Application(Internal::Adaptor::Application* application)
+: BaseHandle(application)
+{
+}
+
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_CALLBACK_MANAGER_H__
+#define __DALI_CALLBACK_MANAGER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+#include <dali/public-api/common/dali-common.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Abstract interface to install call backs in to an applications main loop.
+ */
+class DALI_IMPORT_API CallbackManager
+{
+
+public:
+
+ typedef boost::function<void(void)> Callback; ///< Callback typedef
+
+ /**
+ * Determines the priority of the call back
+ */
+ enum Priority
+ {
+ IDLE_PRIORITY, ///< idle priority
+ DEFAULT_PRIORITY, ///< priority of the callback will be the same as input handlers and timer callbacks.
+ };
+
+ /**
+ * Controls whether an event once processed by the handler is passed on to other
+ * handlers, or not.
+ */
+ enum EventControl
+ {
+ CALLBACK_PASS_ON, ///< Pass the event on to any other handlers registered for this event
+ CALLBACK_DONE, ///< Don't pass the event to any other handlers
+ };
+
+ /**
+ * Create a new call back interface
+ */
+ static CallbackManager* New();
+
+ /**
+ * Virtual destructor
+ */
+ virtual ~CallbackManager() {}
+
+ /**
+ * Adds a call back asynchronously.
+ * Can be called from any thread.
+ * @param callback custom call back function
+ * @param priority call back priority
+ * @return true on success
+ */
+ virtual bool AddCallback( Callback callback, Priority priority ) = 0;
+
+ /**
+ * Adds a call back asynchronously to handle an event.
+ * E.g. to handle a CTRL-C event.
+ * Can be called from any thread.
+ * @param callback custom call back function
+ * @return true on success
+ */
+ virtual bool AddEventCallback( Callback callback, int type, EventControl control ) = 0;
+
+ /**
+ * Starts the callback manager.
+ */
+ virtual void Start() = 0;
+
+ /**
+ * Stop the callback manager and can remove all pending callbacks synchronously.
+ * This call will synchronise with the main loop and not return
+ * until all call backs have been deleted.
+ */
+ virtual void Stop() = 0;
+
+protected:
+
+ /**
+ * constructor
+ */
+ CallbackManager() {}
+
+private:
+
+ // Undefined copy constructor.
+ CallbackManager( const CallbackManager& );
+
+ // Undefined assignment operator.
+ CallbackManager& operator=( const CallbackManager& );
+
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_CALLBACK_MANAGER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "clipboard-event-notifier-impl.h"
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/dali-core.h>
+
+// INTERNAL INCLUDES
+#include <adaptor-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+BaseHandle Create()
+{
+ BaseHandle handle( ClipboardEventNotifier::Get() );
+
+ if ( !handle && Adaptor::IsAvailable() )
+ {
+ Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
+ Dali::ClipboardEventNotifier notifier( ClipboardEventNotifier::New() );
+ adaptorImpl.RegisterSingleton( typeid( notifier ), notifier );
+ handle = notifier;
+ }
+
+ return handle;
+}
+TypeRegistration CLIPBOARD_EVENT_NOTIFIER_TYPE( typeid(Dali::ClipboardEventNotifier), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
+
+} // unnamed namespace
+
+Dali::ClipboardEventNotifier ClipboardEventNotifier::New()
+{
+ Dali::ClipboardEventNotifier notifier = Dali::ClipboardEventNotifier(new ClipboardEventNotifier());
+
+ return notifier;
+}
+
+Dali::ClipboardEventNotifier ClipboardEventNotifier::Get()
+{
+ Dali::ClipboardEventNotifier notifier;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::ClipboardEventNotifier ) );
+ if(handle)
+ {
+ // If so, downcast the handle
+ notifier = Dali::ClipboardEventNotifier( dynamic_cast< ClipboardEventNotifier* >( handle.GetObjectPtr() ) );
+ }
+ }
+
+ return notifier;
+}
+
+const std::string& ClipboardEventNotifier::GetContent() const
+{
+ return mContent;
+}
+
+void ClipboardEventNotifier::SetContent( const std::string& content )
+{
+ mContent = content;
+}
+
+void ClipboardEventNotifier::ClearContent()
+{
+ mContent.clear();
+}
+
+void ClipboardEventNotifier::EmitContentSelectedSignal()
+{
+ if ( !mContentSelectedSignalV2.Empty() )
+ {
+ Dali::ClipboardEventNotifier handle( this );
+ mContentSelectedSignalV2.Emit( handle );
+ }
+}
+
+ClipboardEventNotifier::ClipboardEventNotifier()
+: mContent()
+{
+}
+
+ClipboardEventNotifier::~ClipboardEventNotifier()
+{
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_CLIPBOARD_EVENT_NOTIFIER_H__
+#define __DALI_INTERNAL_CLIPBOARD_EVENT_NOTIFIER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/math/vector2.h>
+#include <clipboard-event-notifier.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * This class listens to Clipboard events.
+ */
+class ClipboardEventNotifier : public Dali::BaseObject
+{
+public:
+
+ typedef Dali::ClipboardEventNotifier::ClipboardEventSignalV2 ClipboardEventSignalV2;
+
+ // Creation
+
+ /**
+ * Create a ClipboardEventNotifier.
+ * @return A newly allocated clipboard-event-notifier.
+ */
+ static Dali::ClipboardEventNotifier New();
+
+ /**
+ * @copydoc Dali::ClipboardEventNotifier::Get()
+ */
+ static Dali::ClipboardEventNotifier Get();
+
+ // Public API
+
+ /**
+ * @copydoc Dali::ClipboardEventNotifier::GetContent() const
+ */
+ const std::string& GetContent() const;
+
+ /**
+ * Sets the selected content.
+ * @param[in] content A string that represents the content that has been selected.
+ */
+ void SetContent( const std::string& content );
+
+ /**
+ * Clears the stored content.
+ */
+ void ClearContent();
+
+ /**
+ * Called when content is selected in the clipboard.
+ */
+ void EmitContentSelectedSignal();
+
+public: // Signals
+
+ /**
+ * @copydoc Dali::ClipboardEventNotifier::ContentSelectedSignal
+ */
+ ClipboardEventSignalV2& ContentSelectedSignal()
+ {
+ return mContentSelectedSignalV2;
+ }
+
+private:
+
+ // Construction & Destruction
+
+ /**
+ * Constructor.
+ */
+ ClipboardEventNotifier();
+
+ /**
+ * Destructor.
+ */
+ virtual ~ClipboardEventNotifier();
+
+ // Undefined
+ ClipboardEventNotifier( const ClipboardEventNotifier& );
+ ClipboardEventNotifier& operator=( ClipboardEventNotifier& );
+
+private:
+
+ std::string mContent; ///< The current selected content.
+
+ ClipboardEventSignalV2 mContentSelectedSignalV2;
+
+public:
+
+ // Helpers for public-api forwarding methods
+
+ inline static Internal::Adaptor::ClipboardEventNotifier& GetImplementation(Dali::ClipboardEventNotifier& detector)
+ {
+ DALI_ASSERT_ALWAYS( detector && "ClipboardEventNotifier handle is empty" );
+
+ BaseObject& handle = detector.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::ClipboardEventNotifier&>(handle);
+ }
+
+ inline static const Internal::Adaptor::ClipboardEventNotifier& GetImplementation(const Dali::ClipboardEventNotifier& detector)
+ {
+ DALI_ASSERT_ALWAYS( detector && "ClipboardEventNotifier handle is empty" );
+
+ const BaseObject& handle = detector.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::ClipboardEventNotifier&>(handle);
+ }
+
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_CLIPBOARD_EVENT_NOTIFIER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <clipboard-event-notifier.h>
+
+// INTERNAL INCLUDES
+#include <clipboard-event-notifier-impl.h>
+
+namespace Dali
+{
+
+const char* const ClipboardEventNotifier::SIGNAL_CONTENT_SELECTED( "content-selected" );
+
+ClipboardEventNotifier::ClipboardEventNotifier()
+{
+}
+
+ClipboardEventNotifier ClipboardEventNotifier::Get()
+{
+ return Internal::Adaptor::ClipboardEventNotifier::Get();
+}
+
+ClipboardEventNotifier::~ClipboardEventNotifier()
+{
+}
+
+const std::string& ClipboardEventNotifier::GetContent() const
+{
+ return Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).GetContent();
+}
+
+void ClipboardEventNotifier::SetContent( const std::string& content )
+{
+ Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).SetContent(content);
+}
+
+void ClipboardEventNotifier::ClearContent()
+{
+ Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).ClearContent();
+}
+
+void ClipboardEventNotifier::EmitContentSelectedSignal()
+{
+ Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).EmitContentSelectedSignal();
+}
+
+ClipboardEventNotifier::ClipboardEventSignalV2& ClipboardEventNotifier::ContentSelectedSignal()
+{
+ return Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).ContentSelectedSignal();
+}
+
+ClipboardEventNotifier::ClipboardEventNotifier( Internal::Adaptor::ClipboardEventNotifier* notifier )
+: BaseHandle( notifier )
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <clipboard.h>
+
+// INTERNAL INCLUDES
+#include <clipboard-impl.h>
+
+namespace Dali
+{
+
+Clipboard::Clipboard()
+{
+}
+Clipboard::~Clipboard()
+{
+}
+Clipboard::Clipboard(Internal::Adaptor::Clipboard *impl)
+ : BaseHandle(impl)
+{
+}
+
+Clipboard Clipboard::Get()
+{
+ return Internal::Adaptor::Clipboard::Get();
+}
+bool Clipboard::SetItem( const std::string &itemData)
+{
+ return GetImplementation(*this).SetItem( itemData );
+}
+
+std::string Clipboard::GetItem( unsigned int index )
+{
+ return GetImplementation(*this).GetItem( index );
+}
+
+unsigned int Clipboard::NumberOfItems()
+{
+ return GetImplementation(*this).NumberOfItems();
+}
+
+void Clipboard::ShowClipboard()
+{
+ GetImplementation(*this).ShowClipboard();
+}
+
+void Clipboard::HideClipboard()
+{
+ GetImplementation(*this).HideClipboard();
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "color-controller-impl.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+Dali::ColorController ColorController::Get()
+{
+ Dali::ColorController colorController;
+ return colorController;
+}
+
+ColorController::ColorController()
+{
+}
+
+ColorController::~ColorController()
+{
+}
+
+bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
+{
+ return false;
+}
+
+bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
+{
+ return false;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_COLOR_CONTROLLER_H__
+#define __DALI_INTERNAL_COLOR_CONTROLLER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/public-api/object/base-object.h>
+#include <color-controller.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Implementation of ColorController
+ */
+class ColorController : public BaseObject
+{
+public:
+
+ /**
+ * Constructor.
+ */
+ ColorController();
+
+ /**
+ * @copydoc Dali::ColorController::Get()
+ */
+ static Dali::ColorController Get();
+
+ /**
+ * @copydoc Dali::ColorController::RetrieveColor(const std::string&, Vector4&)
+ */
+ bool RetrieveColor( const std::string& colorCode, Vector4& colorValue );
+
+ /**
+ *copydoc Dali::ColorController::RetrieveColor(const std::string&, Vector4&, Vector4&, Vector4&)
+ */
+ bool RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor);
+
+protected:
+ /**
+ * Destructor.
+ */
+ virtual ~ColorController();
+
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+// Additional Helpers for public-api forwarding methods
+inline Internal::Adaptor::ColorController& GetImplementation(Dali::ColorController& controller)
+{
+ DALI_ASSERT_ALWAYS(controller && "ColorController handle is empty");
+ BaseObject& handle = controller.GetBaseObject();
+ return static_cast<Internal::Adaptor::ColorController&>(handle);
+}
+
+inline const Internal::Adaptor::ColorController& GetImplementation(const Dali::ColorController& controller)
+{
+ DALI_ASSERT_ALWAYS(controller && "ColorController handle is empty");
+ const BaseObject& handle = controller.GetBaseObject();
+ return static_cast<const Internal::Adaptor::ColorController&>(handle);
+}
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_COLOR_CONTROLLER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <color-controller.h>
+
+// INTERNAL INCLUDES
+#include <color-controller-impl.h>
+
+namespace Dali
+{
+
+ColorController::ColorController()
+{
+}
+
+ColorController::ColorController(const ColorController& controller)
+: BaseHandle(controller)
+{
+}
+
+ColorController ColorController::Get()
+{
+ return Internal::Adaptor::ColorController::Get();
+}
+
+ColorController::~ColorController()
+{
+}
+
+bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
+{
+ return GetImplementation(*this).RetrieveColor( colorCode, colorValue );
+}
+
+bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
+{
+ return GetImplementation(*this).RetrieveColor( colorCode, textColor, textOutlineColor, textShadowColor );
+}
+
+ColorController::ColorController(Internal::Adaptor::ColorController* internal)
+: BaseHandle(internal)
+{
+}
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "command-line-options.h"
+
+// EXTERNAL INCLUDES
+#include <getopt.h>
+#include <stdlib.h>
+#include <string.h>
+#include <iostream>
+
+#include <dali/public-api/common/vector-wrapper.h>
+
+using namespace std;
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+struct Argument
+{
+ const char * const opt;
+ const char * const optDescription;
+
+ void Print()
+ {
+ const ios_base::fmtflags flags = cout.flags();
+ cout << left << " --";
+ cout.width( 18 );
+ cout << opt;
+ cout << optDescription;
+ cout << endl;
+ cout.flags( flags );
+ }
+};
+
+Argument EXPECTED_ARGS[] =
+{
+ { "no-vsync", "Disable VSync on Render" },
+ { "width", "Stage Width" },
+ { "height", "Stage Height" },
+ { "dpi", "Emulated DPI" },
+ { "view", "Stereocopic 3D view mode ([0]=MONO, 1=STEREO_HORZ, 2=STEREO_VERT, 3=STEREO_INTERLACED)" },
+ { "stereo-base", "Distance in millimeters between left/right cameras [65.0]" },
+ { "help", "Help" },
+ { NULL, NULL }
+};
+
+enum Option
+{
+ OPTION_NO_VSYNC = 0,
+ OPTION_STAGE_WIDTH,
+ OPTION_STAGE_HEIGHT,
+ OPTION_DPI,
+ OPTION_STEREO_MODE,
+ OPTION_STEREO_BASE,
+ OPTION_HELP
+};
+
+typedef vector< int > UnhandledContainer;
+
+void ShowHelp()
+{
+ cout << "Available options:" << endl;
+ Argument* arg = EXPECTED_ARGS;
+ while ( arg->opt )
+ {
+ arg->Print();
+ ++arg;
+ }
+}
+
+} // unnamed namespace
+
+CommandLineOptions::CommandLineOptions(int *argc, char **argv[])
+: noVSyncOnRender(0),
+ stageWidth(0), stageHeight(0),
+ viewMode(0),
+ stereoBase(65)
+{
+ if ( *argc > 1 )
+ {
+ // We do not want to print out errors.
+ int origOptErrValue( opterr );
+ opterr = 0;
+
+ int help( 0 );
+
+ const struct option options[]=
+ {
+ { EXPECTED_ARGS[OPTION_NO_VSYNC].opt, no_argument, &noVSyncOnRender, 1 }, // "--no-vsync"
+ { EXPECTED_ARGS[OPTION_STAGE_WIDTH].opt, required_argument, NULL, 'w' }, // "--width"
+ { EXPECTED_ARGS[OPTION_STAGE_HEIGHT].opt, required_argument, NULL, 'h' }, // "--height"
+ { EXPECTED_ARGS[OPTION_DPI].opt, required_argument, NULL, 'd' }, // "--dpi"
+ { EXPECTED_ARGS[OPTION_STEREO_MODE].opt, required_argument, NULL, 'v' }, // "--view"
+ { EXPECTED_ARGS[OPTION_STEREO_BASE].opt, required_argument, NULL, 's' }, // "--stereo-base"
+ { EXPECTED_ARGS[OPTION_HELP].opt, no_argument, &help, '?' }, // "--help"
+ { 0, 0, 0, 0 } // end of options
+ };
+
+ int shortOption( 0 );
+ int optionIndex( 0 );
+
+ const char* optString = "-w:h:d:v:s:"; // The '-' ensures that argv is NOT permuted
+ bool optionProcessed( false );
+
+ UnhandledContainer unhandledOptions; // We store indices of options we do not handle here
+
+ do
+ {
+ shortOption = getopt_long( *argc, *argv, optString, options, &optionIndex );
+
+ switch ( shortOption )
+ {
+ case 0:
+ {
+ // Check if we want help
+ if ( help )
+ {
+ ShowHelp();
+ optionProcessed = true;
+ }
+ break;
+ }
+
+ case 'w':
+ {
+ if ( optarg )
+ {
+ stageWidth = atoi( optarg );
+ optionProcessed = true;
+ }
+ break;
+ }
+
+ case 'h':
+ {
+ if ( optarg )
+ {
+ stageHeight = atoi( optarg );
+ optionProcessed = true;
+ }
+ break;
+ }
+
+ case 'd':
+ {
+ if ( optarg )
+ {
+ stageDPI.assign( optarg );
+ optionProcessed = true;
+ }
+ break;
+ }
+
+ case 'v':
+ {
+ if ( optarg )
+ {
+ viewMode = atoi(optarg);
+ optionProcessed = true;
+ }
+ break;
+ }
+
+ case 's':
+ {
+ if ( optarg )
+ {
+ stereoBase = atoi(optarg);
+ optionProcessed = true;
+ }
+ break;
+ }
+
+ case -1:
+ {
+ // All command-line options have been parsed.
+ break;
+ }
+
+ default:
+ {
+ unhandledOptions.push_back( optind - 1 );
+ break;
+ }
+ }
+ } while ( shortOption != -1 );
+
+ // Take out the options we have processed
+ if ( optionProcessed )
+ {
+ if ( !unhandledOptions.empty() )
+ {
+ int index( 1 );
+
+ // Overwrite the argv with the values from the unhandled indices
+ const UnhandledContainer::const_iterator endIter = unhandledOptions.end();
+ for ( UnhandledContainer::iterator iter = unhandledOptions.begin(); iter != endIter; ++iter )
+ {
+ (*argv)[ index++ ] = (*argv)[ *iter ];
+ }
+ *argc = unhandledOptions.size() + 1; // +1 for the program name
+ }
+ else
+ {
+ // There are no unhandled options, so we should just have the program name
+ *argc = 1;
+ }
+
+ optind = 1; // Reset to start
+ }
+
+ opterr = origOptErrValue; // Reset opterr value.
+ }
+}
+
+CommandLineOptions::~CommandLineOptions()
+{
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_COMMAND_LINE_OPTIONS_H__
+#define __DALI_INTERNAL_COMMAND_LINE_OPTIONS_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Parses the passed command line arguments and sets the values stored within this
+ * class appropriately.
+ *
+ * The following options are supported:
+ *
+ * @code
+ * --no-vsync Disable VSync on Render
+ * -w|--width Stage Width
+ * -h|--height Stage Height
+ * -d|--dpi Emulated DPI
+ * --help Help
+ * @endcode
+ *
+ * When the above options are found, they are stripped from argv, and argc is updated appropriately.
+ */
+struct CommandLineOptions
+{
+public:
+
+ /**
+ * Constructor
+ * @param[in,out] argc The number of arguments
+ * @param[in,out] argv The argument list
+ * @note Supported options are stripped from argv, and argc is updated appropriately.
+ */
+ CommandLineOptions(int *argc, char **argv[]);
+
+ /**
+ * Destructor
+ */
+ ~CommandLineOptions();
+
+public: // Command line parsed values
+
+ int noVSyncOnRender; ///< If 1, then the user does not want VSync on Render
+ int stageWidth; ///< The width of the stage required. 0 if not set.
+ int stageHeight; ///< The height of the stage required. 0 if not set.
+ int viewMode; ///< Stereocopic 3D view mode (0=MONO, 1=STEREO_HORZ, 2=STEREO_VERT, 3=STEREO_INTERLACED)
+ int stereoBase; ///< The distance in millimeters between left/right cameras
+ std::string stageDPI; ///< DPI stored as hxv, where h is horizontal DPI and v is vertical DPI
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_COMMAND_LINE_OPTIONS_H__
--- /dev/null
+#ifndef __DALI_INTERNAL_DAMAGE_OBSERVER_H__
+#define __DALI_INTERNAL_DAMAGE_OBSERVER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
+
+#include <dali/public-api/math/rect.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+typedef Rect<int> DamageArea;
+
+/**
+ * The DamageObserver can be overridden in order to listen to damage events.
+ */
+class DamageObserver
+{
+public:
+
+ /**
+ * Deriving classes should override this to be notified when we receive a damage event.
+ * @param[in] area The area that has been damaged.
+ */
+ virtual void OnDamaged( const DamageArea& area ) = 0;
+
+protected:
+
+ /**
+ * Protected Constructor.
+ */
+ DamageObserver()
+ {
+ }
+
+ /**
+ * Protected virtual destructor.
+ */
+ virtual ~DamageObserver()
+ {
+ }
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_DAMAGE_OBSERVER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <device-layout.h>
+
+namespace Dali
+{
+
+const DeviceLayout DeviceLayout::DEFAULT_BASE_LAYOUT
+(
+ Vector2(720.0f, 1280.0f), // The resolution of the screen
+ 4.65f, // The screen size
+ Vector2(316.0f, 316.0f), // The DPI
+ 30.0f // The Viewing Distance
+);
+
+DeviceLayout::DeviceLayout()
+: resolution(),
+ screenSize(0.0f),
+ dpi(),
+ viewingDistance(0.0f)
+{
+}
+
+DeviceLayout::DeviceLayout(Vector2 resolution, float screenSize, Vector2 dpi, float viewingDistance)
+: resolution(resolution),
+ screenSize(screenSize),
+ dpi(dpi),
+ viewingDistance(viewingDistance)
+{
+}
+
+DeviceLayout::~DeviceLayout()
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "drag-and-drop-detector-impl.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+Dali::DragAndDropDetector DragAndDropDetector::New()
+{
+ Dali::DragAndDropDetector detector = Dali::DragAndDropDetector(new DragAndDropDetector());
+
+ return detector;
+}
+
+const std::string& DragAndDropDetector::GetContent() const
+{
+ return mContent;
+}
+
+Vector2 DragAndDropDetector::GetCurrentScreenPosition() const
+{
+ return mScreenPosition;
+}
+
+bool DragAndDropDetector::IsEnabled() const
+{
+ return !mDroppedSignalV2.Empty() || !mEnteredSignalV2.Empty() || !mExitedSignalV2.Empty() || !mMovedSignalV2.Empty() ;
+}
+
+void DragAndDropDetector::SetContent( const std::string& content )
+{
+ mContent = content;
+}
+
+void DragAndDropDetector::ClearContent()
+{
+ mContent.clear();
+}
+
+void DragAndDropDetector::SetPosition( Vector2 screenPosition )
+{
+ mScreenPosition = screenPosition;
+}
+
+void DragAndDropDetector::EmitEnteredSignal()
+{
+ if ( !mEnteredSignalV2.Empty() )
+ {
+ Dali::DragAndDropDetector handle( this );
+ mEnteredSignalV2.Emit( handle );
+ }
+}
+
+void DragAndDropDetector::EmitExitedSignal()
+{
+ if ( !mExitedSignalV2.Empty() )
+ {
+ Dali::DragAndDropDetector handle( this );
+ mExitedSignalV2.Emit( handle );
+ }
+}
+
+void DragAndDropDetector::EmitMovedSignal()
+{
+ if ( !mMovedSignalV2.Empty() )
+ {
+ Dali::DragAndDropDetector handle( this );
+ mMovedSignalV2.Emit( handle );
+ }
+}
+
+void DragAndDropDetector::EmitDroppedSignal()
+{
+ if ( !mDroppedSignalV2.Empty() )
+ {
+ Dali::DragAndDropDetector handle( this );
+ mDroppedSignalV2.Emit( handle );
+ }
+}
+
+DragAndDropDetector::DragAndDropDetector()
+: mContent(),
+ mScreenPosition()
+{
+}
+
+DragAndDropDetector::~DragAndDropDetector()
+{
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__
+#define __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/math/vector2.h>
+#include <drag-and-drop-detector.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+typedef IntrusivePtr< DragAndDropDetector > DragAndDropDetectorPtr;
+
+/**
+ * This class listens to Drag & Drop events.
+ */
+class DragAndDropDetector : public Dali::BaseObject
+{
+public:
+
+ typedef Dali::DragAndDropDetector::DragAndDropSignalV2 DragAndDropSignalV2;
+
+ // Creation
+
+ /**
+ * Create a DragAndDropDetector.
+ * This should only be called once by the Window class.
+ * @return A newly allocated drag-and-drop-detector.
+ */
+ static Dali::DragAndDropDetector New();
+
+ // Public API
+
+ /**
+ * @copydoc Dali::DragAndDropDetector::GetContent() const
+ */
+ const std::string& GetContent() const;
+
+ /**
+ * @copydoc Dali::DragAndDropDetector::GetCurrentScreenPosition() const
+ */
+ Vector2 GetCurrentScreenPosition() const;
+
+ // Called by Drag & Drop Event Handler
+
+ /**
+ * Queries whether drag & drop behaviour is really required.
+ * @return true if drag & drop required, false otherwise.
+ */
+ bool IsEnabled() const;
+
+ /**
+ * Sets the dragged content.
+ * @param[in] content A string that represents the content that has been dropped.
+ */
+ void SetContent( const std::string& content );
+
+ /**
+ * Clears the stored content.
+ */
+ void ClearContent();
+
+ /**
+ * Sets the position the drop occurred.
+ */
+ void SetPosition( Vector2 screenPosition );
+
+ /**
+ * Called when a draggable object enters our window.
+ */
+ void EmitEnteredSignal();
+
+ /**
+ * Called when a draggable object leaves our window.
+ */
+ void EmitExitedSignal();
+
+ /**
+ * Called when a draggable object leaves our window.
+ */
+ void EmitMovedSignal();
+
+ /**
+ * Is called when a drop actually occurs.
+ */
+ void EmitDroppedSignal();
+
+public: // Signals
+
+ /**
+ * @copydoc Dali::DragAndDropDetector::EnteredSignal
+ */
+ DragAndDropSignalV2& EnteredSignal()
+ {
+ return mEnteredSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::DragAndDropDetector::ExitedSignal
+ */
+ DragAndDropSignalV2& ExitedSignal()
+ {
+ return mExitedSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::DragAndDropDetector::MovedSignal
+ */
+ DragAndDropSignalV2& MovedSignal()
+ {
+ return mMovedSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::DragAndDropDetector::DroppedSignal
+ */
+ DragAndDropSignalV2& DroppedSignal()
+ {
+ return mDroppedSignalV2;
+ }
+
+private:
+
+ // Construction & Destruction
+
+ /**
+ * Constructor.
+ */
+ DragAndDropDetector();
+
+ /**
+ * Destructor.
+ */
+ virtual ~DragAndDropDetector();
+
+ // Undefined
+ DragAndDropDetector( const DragAndDropDetector& );
+ DragAndDropDetector& operator=( DragAndDropDetector& );
+
+private:
+
+ std::string mContent; ///< The current Drag & drop content.
+ Vector2 mScreenPosition; ///< The screen position of the drop location.
+
+ DragAndDropSignalV2 mEnteredSignalV2;
+ DragAndDropSignalV2 mExitedSignalV2;
+ DragAndDropSignalV2 mMovedSignalV2;
+ DragAndDropSignalV2 mDroppedSignalV2;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Internal::Adaptor::DragAndDropDetector& GetImplementation(Dali::DragAndDropDetector& detector)
+{
+ DALI_ASSERT_ALWAYS( detector && "DragAndDropDetector handle is empty" );
+
+ BaseObject& handle = detector.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::DragAndDropDetector&>(handle);
+}
+
+inline const Internal::Adaptor::DragAndDropDetector& GetImplementation(const Dali::DragAndDropDetector& detector)
+{
+ DALI_ASSERT_ALWAYS( detector && "DragAndDropDetector handle is empty" );
+
+ const BaseObject& handle = detector.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::DragAndDropDetector&>(handle);
+}
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <drag-and-drop-detector.h>
+
+// INTERNAL INCLUDES
+#include <drag-and-drop-detector-impl.h>
+
+namespace Dali
+{
+
+const char* const DragAndDropDetector::SIGNAL_ENTERED( "drag-and-drop-entered" );
+const char* const DragAndDropDetector::SIGNAL_EXITED( "drag-and-drop-exited" );
+const char* const DragAndDropDetector::SIGNAL_MOVED( "drag-and-drop-moved" );
+const char* const DragAndDropDetector::SIGNAL_DROPPED( "drag-and-drop-dropped" );
+
+DragAndDropDetector::DragAndDropDetector()
+{
+}
+
+DragAndDropDetector::~DragAndDropDetector()
+{
+}
+
+const std::string& DragAndDropDetector::GetContent() const
+{
+ return GetImplementation(*this).GetContent();
+}
+
+Vector2 DragAndDropDetector::GetCurrentScreenPosition() const
+{
+ return GetImplementation(*this).GetCurrentScreenPosition();
+}
+
+DragAndDropDetector::DragAndDropSignalV2& DragAndDropDetector::EnteredSignal()
+{
+ return GetImplementation(*this).EnteredSignal();
+}
+
+DragAndDropDetector::DragAndDropSignalV2& DragAndDropDetector::ExitedSignal()
+{
+ return GetImplementation(*this).ExitedSignal();
+}
+
+DragAndDropDetector::DragAndDropSignalV2& DragAndDropDetector::MovedSignal()
+{
+ return GetImplementation(*this).MovedSignal();
+}
+
+DragAndDropDetector::DragAndDropSignalV2& DragAndDropDetector::DroppedSignal()
+{
+ return GetImplementation(*this).DroppedSignal();
+}
+
+DragAndDropDetector::DragAndDropDetector( Internal::Adaptor::DragAndDropDetector* detector )
+: BaseHandle( detector )
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "ecore-callback-manager.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Structure contains the callback function and control options
+ */
+struct CallbackData
+{
+ /**
+ * the type of callback
+ */
+ enum CallbackType
+ {
+ STANDARD_CALLBACK, ///< either an idle call back, or a default call back
+ EVENT_HANDLER ///< event handler
+ };
+
+ /**
+ * Constructor
+ */
+ CallbackData(CallbackManager::Callback callback, CallbackType type):
+ mCallback(callback),
+ mType(type),
+ mIdler(NULL),
+ mPriority(CallbackManager::DEFAULT_PRIORITY),
+ mExecute(true),
+ mEventHandler(NULL),
+ mEvent(0),
+ mEventControl(CallbackManager::CALLBACK_PASS_ON)
+ {
+ }
+
+ // Data
+ CallbackManager::Callback mCallback; ///< call back
+ CallbackType mType; ///< type of call back
+
+ // Data for idle / default call backs
+ Ecore_Idler* mIdler; ///< ecore idler
+ CallbackManager::Priority mPriority; ///< Priority (idle or normal)
+ bool mExecute; ///< whether to run the callback
+
+ // Data for event handlers
+ Ecore_Event_Handler* mEventHandler; ///< ecore handler
+ int mEvent; ///< ecore event id
+ CallbackManager::EventControl mEventControl; ///< event control
+
+ // function typedef to remove the callbackdata from the callback container
+ typedef boost::function<void(CallbackData *)> RemoveFromContainerFunction;
+
+ RemoveFromContainerFunction mRemoveFromContainerFunction;
+};
+
+namespace
+{
+
+/**
+ * Called from the main thread while idle.
+ */
+Eina_Bool IdleCallback(void *data)
+{
+ CallbackData *callbackData = static_cast<CallbackData *>(data);
+
+ // remove callback data from the container first in case our callback tries to modify the container
+ callbackData->mRemoveFromContainerFunction(callbackData);
+
+ // run the function
+ callbackData->mCallback();
+
+ // remove the idle call back
+ ecore_idler_del(callbackData->mIdler);
+
+ delete callbackData;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+/**
+ * Ecore callback event handler, called from the main thread
+ * @param data user data
+ * @param type event type, e.g. ECORE_EVENT_SIGNAL_EXIT
+ * @param event pointer to ecore event
+ */
+Eina_Bool EventHandler(void *data, int type, void *event)
+{
+ CallbackData* callbackData = static_cast<CallbackData*>(data);
+
+ // make sure the type is for the right event
+ DALI_ASSERT_ALWAYS( type == callbackData->mEvent && "Callback data does not match event" );
+
+ // remove callback data from the container first in case our callback tries to modify the container
+ callbackData->mRemoveFromContainerFunction(callbackData);
+
+ // run the call back
+ callbackData->mCallback();
+
+ Eina_Bool returnVal;
+
+ if (callbackData->mEventControl == CallbackManager::CALLBACK_PASS_ON)
+ {
+ returnVal = ECORE_CALLBACK_PASS_ON;
+ }
+ else
+ {
+ returnVal = ECORE_CALLBACK_DONE;
+ }
+
+ delete callbackData;
+
+ return returnVal;
+}
+
+/**
+ * called from MainLoopCallback to process standard callbacks
+ */
+void AddStandardCallback(CallbackData *callbackData)
+{
+ if (callbackData->mPriority == CallbackManager::IDLE_PRIORITY)
+ {
+ // run the call back on idle
+ callbackData->mIdler = ecore_idler_add(IdleCallback, callbackData);
+ DALI_ASSERT_ALWAYS( callbackData->mIdler != NULL && "Idle method not created" );
+ }
+ else
+ {
+ // run the call back now, then delete it from the container
+ if ( callbackData->mExecute )
+ {
+ callbackData->mCallback();
+ }
+ callbackData->mRemoveFromContainerFunction(callbackData);
+ delete callbackData;
+ }
+}
+
+/**
+ * called from MainLoopCallback to add event callbacks
+ */
+void AddEventCallback(CallbackData *callbackData)
+{
+ callbackData->mEventHandler = ecore_event_handler_add(callbackData->mEvent, &EventHandler, callbackData);
+}
+
+/**
+ * main loop call back to process call back data.
+ */
+void MainLoopCallback(void *data)
+{
+ CallbackData *callbackData = static_cast< CallbackData* >(data);
+
+ if (callbackData->mType == CallbackData::STANDARD_CALLBACK)
+ {
+ AddStandardCallback(callbackData);
+ }
+ else if (callbackData->mType == CallbackData::EVENT_HANDLER)
+ {
+ AddEventCallback(callbackData);
+ }
+}
+
+/**
+ * Main loop call back to remove all call back data
+ */
+void* MainRemoveAllCallback(void* data)
+{
+ EcoreCallbackManager *callbackManager = static_cast<EcoreCallbackManager *>(data);
+
+ callbackManager->RemoveAllCallbacksFromMainThread();
+
+ return NULL;
+}
+
+} // unnamed namespace
+
+EcoreCallbackManager::EcoreCallbackManager()
+:mRunning(false)
+{
+}
+
+void EcoreCallbackManager::RemoveStandardCallback(CallbackData *callbackData)
+{
+ if (callbackData->mPriority == CallbackManager::IDLE_PRIORITY)
+ {
+ // delete the idle call back
+ ecore_idler_del(callbackData->mIdler);
+ delete callbackData;
+ }
+ else
+ {
+ // ecore doesn't give us a handle for functions we want executing on the
+ // main thread, E.g. we can't do
+ // handle = ecore_main_loop_thread_safe_call_async( myfunc )
+ // ecore_main_loop_thread_remove_async_call(handle); // doesn't exist
+ //
+ // We just have to set a flag to say do not execute.
+ // Hence we can't delete the call back at this point.
+ callbackData->mExecute = false;
+ }
+}
+
+void EcoreCallbackManager::RemoveEventCallback(CallbackData *callbackData)
+{
+ ecore_event_handler_del(callbackData->mEventHandler);
+
+ delete callbackData;
+}
+
+void EcoreCallbackManager::Start()
+{
+ DALI_ASSERT_DEBUG( mRunning == false );
+
+ mRunning = true;
+}
+
+void EcoreCallbackManager::Stop()
+{
+ // make sure we're not called twice
+ DALI_ASSERT_DEBUG( mRunning == true );
+
+ // lock out any other call back functions
+ boost::unique_lock< boost::mutex > lock( mMutex );
+
+ mRunning = false;
+
+ // the synchronous calls return data from the callback, which we ignore.
+ ecore_main_loop_thread_safe_call_sync(MainRemoveAllCallback, this);
+}
+
+bool EcoreCallbackManager::AddCallback(Callback callback, Priority priority)
+{
+ bool added(false);
+
+ if ( mRunning )
+ {
+ CallbackData *callbackData = new CallbackData(callback, CallbackData::STANDARD_CALLBACK);
+
+ callbackData->mPriority = priority;
+
+ callbackData->mRemoveFromContainerFunction = boost::bind(&EcoreCallbackManager::RemoveCallbackFromContainer, this,_1);
+
+ { // acquire lock to access container
+ boost::unique_lock< boost::mutex > lock( mMutex );
+
+ // add the call back to the container
+ mCallbackContainer.push_front(callbackData);
+ }
+
+ // Get callbackData processed on the main loop..
+
+ ecore_main_loop_thread_safe_call_async(MainLoopCallback, callbackData);
+
+ added = true;
+ }
+
+ return added;
+}
+
+bool EcoreCallbackManager::AddEventCallback(Callback callback, int type, EventControl control)
+{
+ bool added(false);
+
+ if( mRunning )
+ {
+ CallbackData *callbackData = new CallbackData(callback,CallbackData::EVENT_HANDLER);
+ callbackData->mEventControl = control;
+ callbackData->mEvent = type;
+
+ callbackData->mRemoveFromContainerFunction = boost::bind(&EcoreCallbackManager::RemoveCallbackFromContainer, this,_1);
+
+ { // acquire lock to access container
+ boost::unique_lock< boost::mutex > lock( mMutex );
+
+ // add the call back to the container
+ mCallbackContainer.push_front(callbackData);
+ }
+
+ // Get callbackData processed on the main loop..
+ ecore_main_loop_thread_safe_call_async(MainLoopCallback, callbackData);
+
+ added = true;
+ }
+
+ return added;
+}
+
+void EcoreCallbackManager::RemoveCallbackFromContainer(CallbackData *callbackData)
+{
+ // always called from main loop
+ boost::unique_lock< boost::mutex > lock( mMutex );
+
+ mCallbackContainer.remove(callbackData);
+}
+
+void EcoreCallbackManager::RemoveAllCallbacksFromMainThread()
+{
+ // always called from main thread
+ // the mutex will already be locked at this point
+
+ for( CallbackList::iterator iter = mCallbackContainer.begin(); iter != mCallbackContainer.end(); ++iter)
+ {
+ CallbackData* data = (*iter);
+
+ if (data->mType == CallbackData::STANDARD_CALLBACK)
+ {
+ RemoveStandardCallback(data);
+ }
+ else if (data->mType == CallbackData::EVENT_HANDLER)
+ {
+ RemoveEventCallback(data);
+ }
+ }
+ mCallbackContainer.clear();
+}
+
+// Creates a concrete interface for CallbackManager
+CallbackManager* CallbackManager::New()
+{
+ return new EcoreCallbackManager;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_ECORE_CALLBACK_MANAGER_H__
+#define __DALI_ECORE_CALLBACK_MANAGER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/thread.hpp>
+#include <list>
+
+// INTERNAL INCLUDES
+#include <callback-manager.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+struct CallbackData;
+
+/**
+ * Ecore interface to install call backs in the applications main loop.
+ */
+class EcoreCallbackManager : public CallbackManager
+{
+
+public:
+
+ /**
+ * constructor
+ */
+ EcoreCallbackManager();
+
+ /**
+ * destructor
+ */
+ ~EcoreCallbackManager()
+ {
+ }
+
+ /**
+ * @copydoc CallbackManager::AddCallback()
+ */
+ virtual bool AddCallback(Callback callback, Priority priority);
+
+ /**
+ * @copydoc CallbackManager::AddEventCallback()
+ */
+ virtual bool AddEventCallback(Callback callback, int type, EventControl control);
+
+ /**
+ * @copydoc CallbackManager::Start()
+ */
+ virtual void Start();
+
+ /**
+ * @copydoc CallbackManager::Stop()
+ */
+ virtual void Stop();
+
+ /**
+ * Remove all call backs
+ * Always called from the main thread
+ */
+ void RemoveAllCallbacksFromMainThread();
+
+private:
+
+ /**
+ * Deletes any expired callbacks in the callback container
+ */
+ void RefreshContainer();
+
+ /**
+ * Removes a single call back from the container
+ * Always called from main thread
+ * @param callbackData callback data
+ */
+ void RemoveCallbackFromContainer(CallbackData *callbackData);
+
+ /**
+ * Remove a standard call back from ecore
+ * Always called from main thread
+ * @param callbackData callback data
+ */
+ void RemoveStandardCallback(CallbackData *callbackData);
+
+ /**
+ * Remove an event handler from ecore
+ * Always called from main thread
+ * @param callbackData callback data
+ */
+ void RemoveEventCallback(CallbackData *callbackData);
+
+
+
+ typedef std::list<CallbackData *> CallbackList;
+
+ bool mRunning; ///< flag is set to true if when running
+ CallbackList mCallbackContainer; ///< container of live callbacks
+ boost::mutex mMutex; ///< protect access to shared data
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_ECORE_CALLBACK_MANAGER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// HEADER
+#include <event-feeder.h>
+
+// INTERNAL INCLUDES
+#include <adaptor-impl.h>
+
+namespace Dali
+{
+
+namespace EventFeeder
+{
+
+void FeedTouchPoint( TouchPoint& point, int timeStamp )
+{
+ if ( Adaptor::IsAvailable() )
+ {
+ Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).FeedTouchPoint( point, timeStamp );
+ }
+}
+
+void FeedWheelEvent( MouseWheelEvent& wheelEvent )
+{
+ if ( Adaptor::IsAvailable() )
+ {
+ Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).FeedWheelEvent( wheelEvent );
+ }
+}
+
+void FeedKeyEvent( KeyEvent& keyEvent )
+{
+ if ( Adaptor::IsAvailable() )
+ {
+ Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).FeedKeyEvent( keyEvent );
+ }
+}
+
+} // namespace EventFeeder
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_EVENT_HANDLER_H__
+#define __DALI_INTERNAL_EVENT_HANDLER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/events/touch-event-combiner.h>
+#include <style-monitor.h>
+
+// INTERNAL INCLUDES
+#include <damage-observer.h>
+#include <drag-and-drop-detector-impl.h>
+#include <accessibility-manager-impl.h>
+#include <clipboard-event-notifier-impl.h>
+#include <imf-manager-impl.h>
+#include <rotation-observer.h>
+
+namespace Dali
+{
+
+struct StyleChange;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class CoreEventInterface;
+class GestureManager;
+class RenderSurface;
+class StyleMonitor;
+
+/**
+ * The Event Handler class is responsible for setting up receiving of Ecore events and then converts them
+ * to TouchEvents when it does receive them.
+ *
+ * These TouchEvents are then passed on to Core.
+ */
+class EventHandler
+{
+public:
+
+ /**
+ * Constructor.
+ * @param[in] surface The surface where events will be sent to.
+ * @param[in] coreEventInterface Used to send events to Core.
+ * @param[in] gestureManager The Gesture Manager.
+ * @param[in] damageObserver The damage observer (to pass damage events to).
+ * @param[in] dndDetector The Drag & Drop listener (to pass DnD events to).
+ */
+ EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector );
+
+ /**
+ * Destructor.
+ */
+ ~EventHandler();
+
+ /**
+ * Feed (Send) touch event to core and gesture manager
+ * @param[in] touchEvent The touch event holding the touch point information.
+ */
+ void FeedTouchPoint( TouchPoint& point, int timeStamp );
+
+ /**
+ * Feed (Send) mouse wheel event to core and gesture manager
+ * @param[in] wheelEvent The mouse wheel event
+ */
+ void FeedWheelEvent( MouseWheelEvent& wheelEvent );
+
+ /**
+ * Feed (Send) key event to core
+ * @param[in] keyEvent The key event holding the key information.
+ */
+ void FeedKeyEvent( KeyEvent& keyEvent );
+
+ /**
+ * Feed (Send) an event to core
+ * @param[in] event The event information.
+ */
+ void FeedEvent( Integration::Event& event );
+
+ /**
+ * Resets the event handler.
+ */
+ void Reset();
+
+ /**
+ * Sets the Drag & Drop detector.
+ * @param[in] detector An intrusive pointer to the Drag & Drop listener to set. To unset pass in NULL.
+ */
+ void SetDragAndDropDetector( DragAndDropDetectorPtr detector );
+
+ /**
+ * Set the rotation observer (note, some adaptors may not have a rotation observer)
+ * @param[in] observer The rotation observer
+ */
+ void SetRotationObserver( RotationObserver* observer );
+
+private:
+
+ /**
+ * Send touch event to core.
+ * @param[in] point The touch point information.
+ * @param[in] timeStamp The time the touch occurred.
+ */
+ void SendEvent(TouchPoint& point, unsigned long timeStamp);
+
+ /**
+ * Send key event to core.
+ * @param[in] keyEvent The KeyEvent to send.
+ */
+ void SendEvent(KeyEvent& keyEvent);
+
+ /**
+ * Send mouse wheel event to core.
+ * @param[in] wheelEvent The mouse wheel event
+ */
+ void SendMouseWheelEvent( MouseWheelEvent& wheelEvent );
+
+ /**
+ * Send a style change event to the style monitor.
+ * @param[in] styleChange The style that has changed.
+ */
+ void SendEvent(StyleChange styleChange);
+
+ /**
+ * Send a window damage event to the observer.
+ * @param[in] area Damaged area.
+ */
+ void SendEvent( const DamageArea& area );
+
+ /**
+ * Inform rotation observer of rotation prepare event
+ * @param[in] rotation The rotation event
+ */
+ void SendRotationPrepareEvent( const RotationEvent& rotation );
+
+ /**
+ * Inform rotation observer of rotation prepare event
+ */
+ void SendRotationRequestEvent( );
+
+private:
+
+ CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
+ Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
+ GestureManager& mGestureManager; ///< Reference to the GestureManager, set on construction, to send touch events to for analysis.
+ Dali::StyleMonitor mStyleMonitor; ///< Handle to the style monitor, set on construction, to send font size and font change events to.
+ DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to.
+ RotationObserver* mRotationObserver; ///< Pointer to rotation observer, if present.
+
+ DragAndDropDetectorPtr mDragAndDropDetector; ///< Pointer to the drag & drop detector, to send Drag & Drop events to.
+ Dali::AccessibilityManager mAccessibilityManager; ///< Pointer to the accessibility manager
+ Dali::ClipboardEventNotifier mClipboardEventNotifier; ///< Pointer to the clipboard event notifier
+ Dali::Clipboard mClipboard;///< Pointer to the clipboard
+ Dali::ImfManager mImfManager; ///< Pointer to the IMF manager.
+
+ struct Impl; ///< Contains Ecore specific information
+ Impl* mImpl; ///< Created on construction and destroyed on destruction.
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_EVENT_HANDLER_H__
--- /dev/null
+#ifndef __DALI_INTERNAL_GESTURE_DETECTOR_H__
+#define __DALI_INTERNAL_GESTURE_DETECTOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/events/gesture.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/object/ref-object.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+class Core;
+class GestureRequest;
+struct TouchEvent;
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Abstract Base class for all adaptor gesture detectors.
+ *
+ * @note this may be replaced by gesture events sent directly from X.
+ */
+class GestureDetector : public RefObject
+{
+public:
+
+ /**
+ * Called by the gesture manager when it gets a touch event. The gesture detector should
+ * evaluate this event along with previously received events to determine whether the gesture
+ * they require has taken place.
+ * @param[in] event The latest touch event.
+ */
+ virtual void SendEvent(const Integration::TouchEvent& event) = 0;
+
+ /**
+ * Called by the gesture manager when Core updates the gesture's detection requirements.
+ * @param[in] request The updated detection requirements.
+ */
+ virtual void Update(const Integration::GestureRequest& request) = 0;
+
+ /**
+ * Returns the type of gesture detector.
+ * @return Type of gesture detector.
+ */
+ Gesture::Type GetType() const { return mType; }
+
+protected:
+
+ /**
+ * Protected Constructor. Should only be able to create derived class objects.
+ * @param[in] screenSize The size of the screen.
+ * @param[in] detectorType The type of gesture detector.
+ */
+ GestureDetector(Vector2 screenSize, Gesture::Type detectorType)
+ : mScreenSize(screenSize), mType(detectorType) {}
+
+ /**
+ * Virtual destructor.
+ */
+ virtual ~GestureDetector() {}
+
+protected:
+
+ Vector2 mScreenSize;
+ Gesture::Type mType;
+};
+
+typedef IntrusivePtr<GestureDetector> GestureDetectorPtr;
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_GESTURE_DETECTOR_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "gesture-manager.h"
+
+// EXTERNAL INCLUDES
+#include <boost/bind.hpp>
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <events/gesture-detector.h>
+#include <events/long-press-gesture-detector.h>
+#include <events/pan-gesture-detector.h>
+#include <events/pinch-gesture-detector.h>
+#include <events/tap-gesture-detector.h>
+#include <base/core-event-interface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+#if defined(DEBUG_ENABLED)
+Integration::Log::Filter* gLogFilter = Integration::Log::Filter::New( Debug::NoLogging, false, "LOG_GESTURE_MANAGER" );
+
+/**
+ * Helper method to return the string representation of a gesture type.
+ */
+const char * GetGestureTypeString( Gesture::Type type )
+{
+ static const char * const pinch( "Pinch" );
+ static const char * const pan( "Pan" );
+ static const char * const tap( "tap" );
+ static const char * const longPress( "LongPress" );
+ static const char * const invalid( "Invalid" );
+
+ const char * retVal( NULL );
+
+ switch ( type )
+ {
+ case Gesture::LongPress:
+ {
+ retVal = longPress;
+ break;
+ }
+
+ case Gesture::Pan:
+ {
+ retVal = pan;
+ break;
+ }
+
+ case Gesture::Pinch:
+ {
+ retVal = pinch;
+ break;
+ }
+
+ case Gesture::Tap:
+ {
+ retVal = tap;
+ break;
+ }
+
+ default:
+ retVal = invalid;
+ break;
+ }
+
+ return retVal;
+};
+#endif // DEBUG_ENABLED
+
+const float MINIMUM_DISTANCE_DELTA_DIVISOR = 85.0f;
+} // unnamed namespace
+
+GestureManager::GestureManager(CoreEventInterface& coreEventInterface, Vector2 screenSize,CallbackManager* callbackManager, EnvironmentOptions& environmentOptions)
+: mCoreEventInterface( coreEventInterface ),
+ mScreenSize( screenSize ),
+ mCallbackManager( callbackManager ),
+ mEnvironmentOptions( environmentOptions ),
+ mMinimumDistanceDelta(-1.0f),
+ mRunning( true ) // This allows gestures to be created before Adaptor::Start() is called e.g. by Indicator
+{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Creating GestureManager\n" );
+}
+
+GestureManager::~GestureManager()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Destroying GestureManager\n" );
+}
+
+void GestureManager::SendEvent(const Integration::TouchEvent& event)
+{
+ if (mRunning)
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SendEvent: START\n" );
+
+ // gestures can be added / deleted during SendEvent so we make a copy of the container.
+ // the gestures are reference counted, so unused gesture detectors will be deleted when
+ // the local variable detectors goes out of scope.
+ GestureDetectorContainer detectors( mGestureDetectors );
+
+ // Send the event to all gesture detectors.
+ for ( GestureDetectorContainer::iterator iter = detectors.begin(), endIter = detectors.end(); iter != endIter; ++iter )
+ {
+ (*iter)->SendEvent(event);
+ }
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SendEvent: END\n" );
+ }
+}
+
+void GestureManager::Stop()
+{
+ if (mRunning)
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Stop\n" );
+
+ mGestureDetectors.clear();
+ mRunning = false;
+ }
+}
+
+void GestureManager::SetMinimumPinchDistance(float distance)
+{
+ mMinimumDistanceDelta = distance;
+ for( GestureDetectorContainer::iterator iter = mGestureDetectors.begin(), endIter = mGestureDetectors.end(); iter != endIter; ++iter )
+ {
+ if ( ( *iter )->GetType() == Gesture::Pinch )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Set Minimum Pinch Distance: %f\n", distance );
+ PinchGestureDetector* gestureDetector = static_cast<PinchGestureDetector*>(iter->Get());
+ gestureDetector->SetMinimumPinchDistance(distance);
+ break;
+ }
+ }
+}
+
+void GestureManager::Register(const Integration::GestureRequest& request)
+{
+ if (mRunning)
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Creating %s Detector\n", GetGestureTypeString( request.type ) );
+
+ switch (request.type)
+ {
+ case Gesture::LongPress:
+ {
+ GestureDetectorPtr gesture = new LongPressGestureDetector(mCoreEventInterface, mScreenSize, static_cast<const Integration::LongPressGestureRequest&>(request));
+ mGestureDetectors.push_back(gesture);
+ break;
+ }
+
+ case Gesture::Pan:
+ {
+ GestureDetectorPtr gesture = new PanGestureDetector(mCoreEventInterface, mScreenSize, static_cast<const Integration::PanGestureRequest&>(request), mEnvironmentOptions);
+ mGestureDetectors.push_back(gesture);
+ break;
+ }
+
+ case Gesture::Pinch:
+ {
+ float minPinchDistance = mMinimumDistanceDelta >= 0.0f ? mMinimumDistanceDelta : (mScreenSize.height / MINIMUM_DISTANCE_DELTA_DIVISOR);
+ GestureDetectorPtr gesture = new PinchGestureDetector(mCoreEventInterface, mScreenSize, minPinchDistance);
+ mGestureDetectors.push_back(gesture);
+ break;
+ }
+
+ case Gesture::Tap:
+ {
+ GestureDetectorPtr gesture = new TapGestureDetector(mCoreEventInterface, mScreenSize, static_cast<const Integration::TapGestureRequest&>(request));
+ mGestureDetectors.push_back(gesture);
+ break;
+ }
+
+ default:
+ DALI_ASSERT_DEBUG(false);
+ break;
+ }
+ }
+}
+
+void GestureManager::Unregister(const Integration::GestureRequest& request)
+{
+ if ( mRunning )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Unregister: %s\n", GetGestureTypeString( request.type ) );
+
+ DeleteGestureDetector( request.type );
+
+ }
+}
+
+void GestureManager::Update(const Integration::GestureRequest& request)
+{
+ for( GestureDetectorContainer::iterator iter = mGestureDetectors.begin(), endIter = mGestureDetectors.end(); iter < endIter; ++iter )
+ {
+ if ( (*iter)->GetType() == request.type )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Update: %s\n", GetGestureTypeString( request.type ) );
+ (*iter)->Update( request );
+ break;
+ }
+ }
+}
+
+void GestureManager::DeleteGestureDetector( Gesture::Type type )
+{
+ for( GestureDetectorContainer::iterator iter = mGestureDetectors.begin(), endIter = mGestureDetectors.end(); iter != endIter; ++iter )
+ {
+ if ( ( *iter )->GetType() == type )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "DeleteGestureDetector: %s\n", GetGestureTypeString( type ) );
+ mGestureDetectors.erase( iter );
+ break;
+ }
+ }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_GESTURE_MANAGER_H__
+#define __DALI_INTERNAL_GESTURE_MANAGER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/integration-api/gesture-manager.h>
+
+// INTERNAL INCLUDES
+#include <events/gesture-detector.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+struct TouchEvent;
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class CallbackManager;
+class CoreEventInterface;
+class EnvironmentOptions;
+
+/**
+ * Implementation of the Integration::GestureManager.
+ *
+ * Contains a list of adaptor gesture detectors. It passes touch events to each required detector which
+ * in turn process them to determine if their corresponding gesture has occurred.
+ */
+class GestureManager : public Integration::GestureManager
+{
+public:
+
+ /**
+ * Constructor.
+ * @param[in] coreEventInterface Used to send events to Core.
+ * @param[in] screenSize The size of the screen.
+ * @param[in] callbackManager used to install callbacks
+ * @param[in] environmentOptions Environment Options
+ */
+ GestureManager(CoreEventInterface& coreEventInterface, Vector2 screenSize, CallbackManager* callbackManager, EnvironmentOptions& environmentOptions);
+
+ /**
+ * The destructor
+ */
+ virtual ~GestureManager();
+
+public:
+
+ /**
+ * Used by the event handler to send touch events to the Gesture Manager.
+ * @param[in] event The latest touch event.
+ */
+ void SendEvent(const Integration::TouchEvent& event);
+
+ /**
+ * Used by the event handler to stop the GestureManager detection.
+ */
+ void Stop();
+
+ /**
+ * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to
+ * trigger a pinch gesture
+ *
+ * @param[in] distance The minimum pinch distance in pixels
+ */
+ void SetMinimumPinchDistance(float distance);
+
+public: // GestureManager overrides
+
+ /**
+ * copydoc Dali::Integration::GestureManager::Register(const Integration::GestureRequest&)
+ */
+ virtual void Register(const Integration::GestureRequest& request);
+
+ /**
+ * copydoc Dali::Integration::GestureManager::Unregister(const Integration::GestureRequest&)
+ */
+ virtual void Unregister(const Integration::GestureRequest& request);
+
+ /**
+ * copydoc Dali::Integration::GestureManager::Unregister(const Integration::GestureRequest&)
+ */
+ virtual void Update(const Integration::GestureRequest& request);
+
+private:
+
+ /**
+ * Used to delete the gesture detector of the given type.
+ */
+ void DeleteGestureDetector( Gesture::Type type );
+
+private:
+
+ typedef std::vector<GestureDetectorPtr> GestureDetectorContainer;
+
+ CoreEventInterface& mCoreEventInterface;
+ GestureDetectorContainer mGestureDetectors;
+ Vector2 mScreenSize;
+ CallbackManager* mCallbackManager;
+ EnvironmentOptions& mEnvironmentOptions;
+ float mMinimumDistanceDelta; ///< The minimum distance before a pinch is applicable. (-1.0f means pinch detector uses default value)
+ bool mRunning; ///< States whether the GestureManager is running or not.
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_GESTURE_MANAGER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "long-press-gesture-detector.h"
+
+// EXTERNAL INCLUDES
+#include <cmath>
+
+#include <dali/public-api/events/touch-point.h>
+#include <dali/public-api/math/vector2.h>
+
+#include <dali/integration-api/events/gesture-requests.h>
+#include <dali/integration-api/events/long-press-gesture-event.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+
+#include <system-settings.h>
+
+// INTERNAL INCLUDES
+#include <base/core-event-interface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+// TODO: Set these according to DPI
+const float MAXIMUM_MOTION_ALLOWED = 60.0f;
+// TODO: Set this time according to system setting (vconf)
+const unsigned long LONG_PRESS_TIME = 500u;
+} // unnamed namespace
+
+LongPressGestureDetector::LongPressGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::LongPressGestureRequest& request)
+: GestureDetector(screenSize, Gesture::LongPress),
+ mCoreEventInterface(coreEventInterface),
+ mState(Clear),
+ mMinimumTouchesRequired(request.minTouches),
+ mMaximumTouchesRequired(request.maxTouches),
+ mTouchTime(0),
+ mTimerSlot( this )
+{
+ mTimer = Dali::Timer::New(GetSystemValue());
+ mTimer.TickSignal().Connect( mTimerSlot, &LongPressGestureDetector::TimerCallback );
+}
+
+LongPressGestureDetector::~LongPressGestureDetector()
+{
+}
+
+void LongPressGestureDetector::SendEvent(const Integration::TouchEvent& event)
+{
+ unsigned int pointCount( event.GetPointCount() );
+
+ switch (mState)
+ {
+ // Clear: Wait till one point touches the screen before starting timer.
+ case Clear:
+ {
+ const TouchPoint& point = event.points[0];
+
+ if ( point.state == TouchPoint::Down )
+ {
+ mTouchPositions.clear();
+ mTouchPositions[point.deviceId] = point.screen;
+
+ mTouchTime = event.time;
+
+ mTimer.SetInterval(GetSystemValue());
+ mTimer.Start();
+
+ // A long press gesture may be possible, tell Core about this and change state to Touched.
+ mState = Touched;
+ EmitGesture( Gesture::Possible );
+ }
+
+ break;
+ }
+
+ // Touched: Monitor movement and addition/removal of points.
+ case Touched:
+ {
+ if (pointCount > mMaximumTouchesRequired)
+ {
+ // A long press did not occur, tell Core that it was cancelled and change state to Failed.
+ EmitGesture( Gesture::Cancelled );
+ mTouchPositions.clear();
+ mTimer.Stop();
+ mState = Failed;
+ break;
+ }
+
+ bool endLoop(false);
+
+ for (std::vector<TouchPoint>::const_iterator iter = event.points.begin(), endIter = event.points.end();
+ iter != endIter && !endLoop; ++iter)
+ {
+ switch( iter->state )
+ {
+ // add point.
+ case TouchPoint::Down:
+ {
+ mTouchPositions[iter->deviceId] = iter->screen;
+ break;
+ }
+
+ // remove point.
+ case TouchPoint::Up:
+ case TouchPoint::Interrupted:
+ {
+ // System has interrupted us, long press is not possible, inform Core
+ EmitGesture( Gesture::Cancelled );
+ mTouchPositions.clear();
+ mTimer.Stop();
+ mState = ( pointCount == 1 ) ? Clear : Failed; // Change state to Clear if only one point, Failed otherwise.
+ endLoop = true;
+ break;
+ }
+
+ case TouchPoint::Motion:
+ {
+ const Vector2 touchPosition( mTouchPositions[iter->deviceId] - iter->screen );
+ float distanceSquared = touchPosition.LengthSquared();
+
+ if (distanceSquared > ( MAXIMUM_MOTION_ALLOWED * MAXIMUM_MOTION_ALLOWED ) )
+ {
+ // We have moved more than the allowable motion for a long press gesture. Inform Core and change state to Failed.
+ EmitGesture( Gesture::Cancelled );
+ mTimer.Stop();
+ mState = Failed;
+ endLoop = true;
+ }
+ break;
+ }
+
+ case TouchPoint::Stationary:
+ case TouchPoint::Leave:
+ case TouchPoint::Last:
+ {
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+ // Failed/Finished: Monitor the touches, waiting for all touches to be released.
+ case Failed:
+ case Finished:
+ {
+ // eventually the final touch point will be removed, marking the end of this gesture.
+ if ( pointCount == 1 )
+ {
+ TouchPoint::State primaryPointState = event.points[0].state;
+
+ if ( (primaryPointState == TouchPoint::Up) || (primaryPointState == TouchPoint::Interrupted) )
+ {
+ if(mState == Finished)
+ {
+ // When the last touch point is lifted, we should inform the Core that the Long press has finished.
+ EmitGesture(Gesture::Finished);
+ }
+ mTouchPositions.clear();
+ mState = Clear; // Reset state to clear when last touch point is lifted.
+ }
+ }
+ break;
+ }
+ }
+}
+
+void LongPressGestureDetector::Update(const Integration::GestureRequest& request)
+{
+ const Integration::LongPressGestureRequest& longPress = static_cast<const Integration::LongPressGestureRequest&>(request);
+
+ mMinimumTouchesRequired = longPress.minTouches;
+ mMaximumTouchesRequired = longPress.maxTouches;
+}
+
+bool LongPressGestureDetector::TimerCallback()
+{
+ EmitGesture(Gesture::Started);
+
+ mState = Finished;
+
+ // There is no touch event at this time, so ProcessEvents must be called directly
+ mCoreEventInterface.ProcessCoreEvents();
+
+ return false;
+}
+
+void LongPressGestureDetector::EmitGesture(Gesture::State state)
+{
+ unsigned int touchPoints ( mTouchPositions.size() );
+
+ // We should tell Core about the Possible and Cancelled states regardless of whether we have satisfied long press requirements.
+ if ( (state == Gesture::Possible) ||
+ (state == Gesture::Cancelled) ||
+ (touchPoints >= mMinimumTouchesRequired) )
+ {
+ Integration::LongPressGestureEvent longPress( state );
+ longPress.numberOfTouches = touchPoints;
+
+ for (std::map<int, Vector2>::iterator iter = mTouchPositions.begin(), endIter = mTouchPositions.end();
+ iter != endIter; ++iter)
+ {
+ longPress.point += iter->second;
+ }
+ longPress.point /= touchPoints;
+
+ longPress.time = mTouchTime;
+ if ( state != Gesture::Possible )
+ {
+ longPress.time += GetSystemValue();
+ }
+
+ mCoreEventInterface.QueueCoreEvent(longPress);
+ }
+}
+
+int LongPressGestureDetector::GetSystemValue()
+{
+ return GetLongPressTime( LONG_PRESS_TIME );
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__
+#define __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <map>
+#include <timer.h>
+
+// INTERNAL INCLUDES
+#include <events/gesture-detector.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+struct TouchEvent;
+struct LongPressGestureRequest;
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class CoreEventInterface;
+
+/**
+ * When given a set of touch events, this detector attempts to determine if a long press gesture has taken place.
+ * Emits a LongPressGestureEvent (state = Started) when a long press has been detected (Touch held down for more than duration).
+ * Emits a further LongPressGestureEvent (state = Finished) when a long press has been completed (Touch Release).
+ */
+class LongPressGestureDetector : public GestureDetector
+{
+public:
+
+ /**
+ * Constructor
+ * @param[in] coreEventInterface Used to send events to Core.
+ * @param[in] screenSize The size of the screen.
+ * @param[in] request The long press gesture request.
+ */
+ LongPressGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::LongPressGestureRequest& request);
+
+ /**
+ * Virtual destructor.
+ */
+ virtual ~LongPressGestureDetector();
+
+public:
+
+ /**
+ * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
+ */
+ virtual void SendEvent(const Integration::TouchEvent& event);
+
+ /**
+ * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
+ */
+ virtual void Update(const Integration::GestureRequest& request);
+
+private:
+
+ /**
+ * Timer Callback
+ * @return will return false; one-shot timer.
+ */
+ bool TimerCallback();
+
+ /**
+ * Emits the long press gesture if all conditions are applicable.
+ * @param[in] state The state of this gesture event.
+ */
+ void EmitGesture(Gesture::State state);
+
+ /**
+ * Get current system setting value for tap and hold gesture
+ * @return system value for tap and hold gesture [ms]
+ */
+ int GetSystemValue();
+
+private:
+
+ /**
+ * Internal state machine.
+ */
+ enum State
+ {
+ Clear, ///< No gesture detected.
+ Touched, ///< User is touching the screen.
+ Failed, ///< Gesture has failed.
+ Finished ///< Gesture has been detected and sent.
+ };
+
+ CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
+ State mState; ///< The current state of the detector.
+
+ unsigned int mMinimumTouchesRequired; ///< The minimum touches required before emitting a long press.
+ unsigned int mMaximumTouchesRequired; ///< The maximum touches allowable. Any more and a long press is not emitted.
+
+ std::map<int, Vector2> mTouchPositions; ///< A map with all the touch down positions.
+ unsigned long mTouchTime; ///< The time we first pressed down.
+
+ Dali::Timer mTimer; ///< The timer used to determine a long press.
+ SlotDelegate< LongPressGestureDetector > mTimerSlot;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "pan-gesture-detector-base.h"
+
+// EXTERNAL INCLUDES
+#include <cmath>
+
+#include <dali/public-api/events/touch-point.h>
+
+#include <dali/integration-api/events/gesture-requests.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+
+// INTERNAL INCLUDES
+#include <base/environment-options.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+const float MINIMUM_MOTION_DISTANCE_BEFORE_PAN( 15.0f );
+const float MINIMUM_MOTION_DISTANCE_BEFORE_PAN_SQUARED( MINIMUM_MOTION_DISTANCE_BEFORE_PAN * MINIMUM_MOTION_DISTANCE_BEFORE_PAN );
+const float MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO( 2.0f / 3.0f );
+const unsigned long MAXIMUM_TIME_DIFF_ALLOWED( 500 );
+const unsigned long MINIMUM_TIME_BEFORE_THRESHOLD_ADJUSTMENTS( 100 );
+const unsigned int MINIMUM_MOTION_EVENTS_BEFORE_PAN(2);
+} // unnamed namespace
+
+PanGestureDetectorBase::PanGestureDetectorBase(Vector2 screenSize, const Integration::PanGestureRequest& request, EnvironmentOptions* environmentOptions)
+: GestureDetector( screenSize, Gesture::Pan ),
+ mState( Clear ),
+ mThresholdAdjustmentsRemaining( 0 ),
+ mThresholdTotalAdjustments( MINIMUM_MOTION_DISTANCE_BEFORE_PAN * MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO ),
+ mPrimaryTouchDownTime( 0 ),
+ mMinimumTouchesRequired( request.minTouches ),
+ mMaximumTouchesRequired( request.maxTouches ),
+ mMinimumDistanceSquared( MINIMUM_MOTION_DISTANCE_BEFORE_PAN_SQUARED ),
+ mMinimumMotionEvents( MINIMUM_MOTION_EVENTS_BEFORE_PAN ),
+ mMotionEvents( 0 )
+{
+ if ( environmentOptions )
+ {
+ int minimumDistance = environmentOptions->GetMinimumPanDistance();
+ if ( minimumDistance >= 0 )
+ {
+ mMinimumDistanceSquared = minimumDistance * minimumDistance;
+
+ // Usually, we do not want to apply the threshold straight away, but phased over the first few pans
+ // Set our distance to threshold adjustments ratio here.
+ mThresholdTotalAdjustments = minimumDistance * MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO;
+ }
+
+ int minimumEvents = environmentOptions->GetMinimumPanEvents();
+ if ( minimumEvents >= 1 )
+ {
+ mMinimumMotionEvents = minimumEvents - 1; // Down is the first event
+ }
+ }
+}
+
+PanGestureDetectorBase::~PanGestureDetectorBase()
+{
+}
+
+void PanGestureDetectorBase::SendEvent(const Integration::TouchEvent& event)
+{
+ TouchPoint::State primaryPointState(event.points[0].state);
+
+ if (primaryPointState == TouchPoint::Interrupted)
+ {
+ if ( ( mState == Started ) || ( mState == Possible ) )
+ {
+ // If our pan had started and we are interrupted, then tell Core that pan is cancelled.
+ mTouchEvents.push_back(event);
+ SendPan(Gesture::Cancelled, event);
+ }
+ mState = Clear; // We should change our state to Clear.
+ mTouchEvents.clear();
+ }
+ else
+ {
+ switch (mState)
+ {
+ case Clear:
+ {
+ if (primaryPointState == TouchPoint::Down)
+ {
+ mPrimaryTouchDownLocation = event.points[0].screen;
+ mPrimaryTouchDownTime = event.time;
+ mMotionEvents = 0;
+ if (event.GetPointCount() == mMinimumTouchesRequired)
+ {
+ // We have satisfied the minimum touches required for a pan, tell core that a gesture may be possible and change our state accordingly.
+ mState = Possible;
+ SendPan(Gesture::Possible, event);
+ }
+
+ mTouchEvents.push_back(event);
+ }
+ break;
+ }
+
+ case Possible:
+ {
+ unsigned int pointCount(event.GetPointCount());
+ if ( (pointCount >= mMinimumTouchesRequired)&&(pointCount <= mMaximumTouchesRequired) )
+ {
+ if (primaryPointState == TouchPoint::Motion)
+ {
+ mTouchEvents.push_back(event);
+ mMotionEvents++;
+
+ Vector2 delta(event.points[0].screen - mPrimaryTouchDownLocation);
+
+ if ( ( mMotionEvents >= mMinimumMotionEvents ) &&
+ ( delta.LengthSquared() >= mMinimumDistanceSquared ) )
+ {
+ // If the touch point(s) have moved enough distance to be considered a pan, then tell Core that the pan gesture has started and change our state accordingly.
+ mState = Started;
+ SendPan(Gesture::Started, event);
+ }
+ }
+ else if (primaryPointState == TouchPoint::Up)
+ {
+ Vector2 delta(event.points[0].screen - mPrimaryTouchDownLocation);
+ if(delta.LengthSquared() >= mMinimumDistanceSquared)
+ {
+ SendPan(Gesture::Started, event);
+ mTouchEvents.push_back(event);
+ SendPan(Gesture::Finished, event);
+ }
+ else
+ {
+ // If we have lifted the primary touch point then tell core the pan is cancelled and change our state to Clear.
+ SendPan(Gesture::Cancelled, event);
+ }
+ mState = Clear;
+ mTouchEvents.clear();
+ }
+ }
+ else
+ {
+ // We do not satisfy pan conditions, tell Core our Gesture has been cancelled.
+ SendPan(Gesture::Cancelled, event);
+
+ if (pointCount == 1 && primaryPointState == TouchPoint::Up)
+ {
+ // If we have lifted the primary touch point, then change our state to Clear...
+ mState = Clear;
+ mTouchEvents.clear();
+ }
+ else
+ {
+ // ...otherwise change it to Failed.
+ mState = Failed;
+ }
+ }
+ break;
+ }
+
+ case Started:
+ {
+ mTouchEvents.push_back(event);
+
+ unsigned int pointCount(event.GetPointCount());
+ if ( (pointCount >= mMinimumTouchesRequired)&&(pointCount <= mMaximumTouchesRequired) )
+ {
+ switch (primaryPointState)
+ {
+ case TouchPoint::Motion:
+ // Pan is continuing, tell Core.
+ SendPan(Gesture::Continuing, event);
+ break;
+
+ case TouchPoint::Up:
+ // Pan is finally finished when our primary point is lifted, tell Core and change our state to Clear.
+ SendPan(Gesture::Finished, event);
+ mState = Clear;
+ mTouchEvents.clear();
+ break;
+
+ case TouchPoint::Stationary:
+ if (pointCount == mMinimumTouchesRequired)
+ {
+ std::vector<TouchPoint>::const_iterator iter = event.points.begin() + 1; // We already know the state of the first point
+ for(; iter != event.points.end(); ++iter)
+ {
+ if(iter->state == TouchPoint::Up)
+ {
+ // The number of touch points will be less than the minimum required. Inform core and change our state to Finished.
+ SendPan(Gesture::Finished, event);
+ mState = Finished;
+ break;
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ else
+ {
+ // We have gone outside of the pan requirements, inform Core that the gesture is finished.
+ SendPan(Gesture::Finished, event);
+
+ if (pointCount == 1 && primaryPointState == TouchPoint::Up)
+ {
+ // If this was the primary point being released, then we change our state back to Clear...
+ mState = Clear;
+ mTouchEvents.clear();
+ }
+ else
+ {
+ // ...otherwise we change it to Finished.
+ mState = Finished;
+ }
+ }
+ break;
+ }
+
+ case Finished:
+ case Failed:
+ {
+ if (primaryPointState == TouchPoint::Up)
+ {
+ // Change our state back to clear when the primary touch point is released.
+ mState = Clear;
+ mTouchEvents.clear();
+ }
+ break;
+ }
+ }
+ }
+}
+
+void PanGestureDetectorBase::Update(const Integration::GestureRequest& request)
+{
+ const Integration::PanGestureRequest& pan = static_cast<const Integration::PanGestureRequest&>(request);
+
+ mMinimumTouchesRequired = pan.minTouches;
+ mMaximumTouchesRequired = pan.maxTouches;
+}
+
+void PanGestureDetectorBase::SendPan(Gesture::State state, const Integration::TouchEvent& currentEvent)
+{
+ Integration::PanGestureEvent gesture(state);
+ gesture.currentPosition = currentEvent.points[0].screen;
+ gesture.numberOfTouches = currentEvent.GetPointCount();
+
+ if ( mTouchEvents.size() > 1 )
+ {
+ // Get the second last event in the queue, the last one is the current event
+ const Integration::TouchEvent& previousEvent( *( mTouchEvents.rbegin() + 1 ) );
+
+ Vector2 previousPosition( mPreviousPosition );
+ unsigned long previousTime( previousEvent.time );
+
+ // If we've just started then we want to remove the threshold from Core calculations.
+ if ( state == Gesture::Started )
+ {
+ previousPosition = mPrimaryTouchDownLocation;
+ previousTime = mPrimaryTouchDownTime;
+
+ // If it's a slow pan, we do not want to phase in the threshold over the first few pan-events
+ // A slow pan is defined as one that starts the specified number of milliseconds after the down-event
+ if ( ( currentEvent.time - previousTime ) > MINIMUM_TIME_BEFORE_THRESHOLD_ADJUSTMENTS )
+ {
+ mThresholdAdjustmentsRemaining = mThresholdTotalAdjustments;
+ mThresholdAdjustmentPerFrame = ( gesture.currentPosition - previousPosition ) / mThresholdTotalAdjustments;
+ }
+ else
+ {
+ mThresholdAdjustmentsRemaining = 0;
+ mThresholdAdjustmentPerFrame = Vector2::ZERO;
+ }
+ }
+
+ gesture.previousPosition = previousPosition;
+ gesture.timeDelta = currentEvent.time - previousTime;
+
+ // Apply the threshold with a phased approach
+ if ( mThresholdAdjustmentsRemaining > 0 )
+ {
+ --mThresholdAdjustmentsRemaining;
+ gesture.currentPosition -= mThresholdAdjustmentPerFrame * mThresholdAdjustmentsRemaining;
+ }
+
+ mPreviousPosition = gesture.currentPosition;
+ }
+ else
+ {
+ gesture.previousPosition = gesture.currentPosition;
+ gesture.timeDelta = 0;
+ }
+
+ gesture.time = currentEvent.time;
+
+ EmitPan(gesture);
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_PAN_GESTURE_DETECTOR_BASE_H__
+#define __DALI_INTERNAL_PAN_GESTURE_DETECTOR_BASE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/integration-api/events/pan-gesture-event.h>
+
+// INTERNAL INCLUDES
+#include <events/gesture-detector.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+class Core;
+struct TouchEvent;
+struct PanGestureRequest;
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class EnvironmentOptions;
+
+/**
+ * When given a set of touch events, this detector attempts to determine if a pan gesture has taken place.
+ */
+class PanGestureDetectorBase : public GestureDetector
+{
+public:
+
+ /**
+ * Virtual destructor.
+ */
+ virtual ~PanGestureDetectorBase();
+
+public:
+
+ /**
+ * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
+ */
+ virtual void SendEvent(const Integration::TouchEvent& event);
+
+ /**
+ * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
+ */
+ virtual void Update(const Integration::GestureRequest& request);
+
+protected:
+
+ /**
+ * Constructor
+ * @param[in] screenSize The size of the screen.
+ * @param[in] request The details of the request.
+ */
+ PanGestureDetectorBase(Vector2 screenSize, const Integration::PanGestureRequest& request, EnvironmentOptions* environmentOptions);
+
+private:
+
+ /**
+ * Emits the pan gesture event (performs some smoothing operation).
+ * @param[in] state The state of the pan.
+ * @param[in] currentEvent The latest touch event.
+ */
+ void SendPan(Gesture::State state, const Integration::TouchEvent& currentEvent);
+
+ /**
+ * Emits the pan gesture event to the core.
+ * @param[in] gesture The pan gesture event.
+ */
+ virtual void EmitPan(const Integration::PanGestureEvent gesture) = 0;
+
+private:
+
+ /**
+ * Internal state machine.
+ */
+ enum State
+ {
+ Clear, ///< No gesture detected.
+ Possible, ///< The current touch event data suggests that a gesture is possible.
+ Started, ///< A gesture has been detected.
+ Finished, ///< A previously started pan gesture has finished.
+ Failed, ///< Current touch event data suggests a pan gesture is not possible.
+ };
+
+ State mState; ///< The current state of the detector.
+ std::vector<Integration::TouchEvent> mTouchEvents; ///< A container of all touch events after an initial down event.
+
+ Vector2 mPrimaryTouchDownLocation; ///< The initial touch down point.
+ Vector2 mThresholdAdjustmentPerFrame; ///< The adjustment per frame at the start of a slow pan.
+ Vector2 mPreviousPosition; ///< The previous position.
+
+ unsigned int mThresholdAdjustmentsRemaining; ///< No. of threshold adjustments still to apply (for a slow-pan).
+ unsigned int mThresholdTotalAdjustments; ///< The total number of adjustments required.
+
+ unsigned long mPrimaryTouchDownTime; ///< The initial touch down time.
+ unsigned int mMinimumTouchesRequired; ///< The minimum touches required before a pan should be emitted.
+ unsigned int mMaximumTouchesRequired; ///< The maximum touches after which a pan should not be emitted.
+
+ unsigned int mMinimumDistanceSquared; ///< The minimum distance squared before pan should start.
+ unsigned int mMinimumMotionEvents; ///< The minimum motion events before pan should start.
+ unsigned int mMotionEvents; ///< The motion events received so far (before pan is emitted).
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_PAN_GESTURE_DETECTOR_BASE_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "pan-gesture-detector.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/events/gesture-requests.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+
+// INTERNAL INCLUDES
+#include <base/core-event-interface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+PanGestureDetector::PanGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::PanGestureRequest& request, EnvironmentOptions& environmentOptions)
+: PanGestureDetectorBase(screenSize, request, &environmentOptions),
+ mCoreEventInterface(coreEventInterface)
+{
+}
+
+PanGestureDetector::~PanGestureDetector()
+{
+}
+
+void PanGestureDetector::EmitPan(const Integration::PanGestureEvent event)
+{
+ mCoreEventInterface.QueueCoreEvent(event);
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_PAN_GESTURE_DETECTOR_H__
+#define __DALI_INTERNAL_PAN_GESTURE_DETECTOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/math/vector2.h>
+
+// INTERNAL INCLUDES
+#include <events/pan-gesture-detector-base.h>
+#include <dali/integration-api/events/pan-gesture-event.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+struct TouchEvent;
+struct PanGestureRequest;
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class CoreEventInterface;
+
+/**
+ * Detects a pan gesture and sends it to core.
+ */
+class PanGestureDetector : public PanGestureDetectorBase
+{
+public:
+
+ /**
+ * Constructor
+ * @param[in] coreEventInterface Used to send events to Core.
+ * @param[in] screenSize The size of the screen.
+ * @param[in] request The details of the request.
+ * @param[in] environmentOptions The environmentOptions.
+ */
+ PanGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::PanGestureRequest& request, EnvironmentOptions& environmentOptions);
+
+ /**
+ * Virtual destructor.
+ */
+ virtual ~PanGestureDetector();
+
+private:
+
+ /**
+ * Emits the pan gesture event to the core.
+ * @param[in] gesture The pan gesture event.
+ */
+ virtual void EmitPan(const Integration::PanGestureEvent gesture);
+
+private:
+
+ CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_PAN_GESTURE_DETECTOR_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "pinch-gesture-detector.h"
+
+// EXTERNAL INCLUDES
+#include <cmath>
+
+#include <dali/public-api/events/touch-point.h>
+#include <dali/public-api/math/vector2.h>
+
+#include <dali/integration-api/events/pinch-gesture-event.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+
+// INTERNAL INCLUDES
+#include <base/core-event-interface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED = 4;
+const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START = 4;
+
+inline float GetDistance(const TouchPoint& point1, const TouchPoint& point2)
+{
+ Vector2 vector(point1.screen - point2.screen);
+ return vector.Length();
+}
+
+inline float GetGradient(const TouchPoint& point1, const TouchPoint& point2)
+{
+ return (point2.screen.y - point1.screen.y)
+ /
+ (point2.screen.x - point1.screen.x);
+}
+
+inline Vector2 GetCenterPoint(const TouchPoint& point1, const TouchPoint& point2)
+{
+ return Vector2(point1.screen + point2.screen) * 0.5f;
+}
+
+} // unnamed namespace
+
+PinchGestureDetector::PinchGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, float minimumPinchDistance)
+: GestureDetector(screenSize, Gesture::Pinch),
+ mCoreEventInterface(coreEventInterface),
+ mState(Clear),
+ mTouchEvents(),
+ mMinimumDistanceDelta(minimumPinchDistance),
+ mStartingDistance(0.0f)
+{
+}
+
+PinchGestureDetector::~PinchGestureDetector()
+{
+}
+
+void PinchGestureDetector::SetMinimumPinchDistance(float distance)
+{
+ mMinimumDistanceDelta = distance;
+}
+
+void PinchGestureDetector::SendEvent(const Integration::TouchEvent& event)
+{
+ int pointCount = event.GetPointCount();
+
+ switch (mState)
+ {
+ case Clear:
+ {
+ if (pointCount == 2)
+ {
+ // Change state to possible as we have two touch points.
+ mState = Possible;
+ mTouchEvents.push_back(event);
+ }
+ break;
+ }
+
+ case Possible:
+ {
+ if (pointCount != 2)
+ {
+ // We no longer have two touch points so change state back to Clear.
+ mState = Clear;
+ mTouchEvents.clear();
+ }
+ else
+ {
+ const TouchPoint& currentPoint1 = event.points[0];
+ const TouchPoint& currentPoint2 = event.points[1];
+
+ if (currentPoint1.state == TouchPoint::Up || currentPoint2.state == TouchPoint::Up)
+ {
+ // One of our touch points has an Up event so change our state back to Clear.
+ mState = Clear;
+ mTouchEvents.clear();
+ }
+ else
+ {
+ mTouchEvents.push_back(event);
+
+ // We can only determine a pinch after a certain number of touch points have been collected.
+ if (mTouchEvents.size() >= MINIMUM_TOUCH_EVENTS_REQUIRED)
+ {
+ const TouchPoint& firstPoint1 = mTouchEvents[0].points[0];
+ const TouchPoint& firstPoint2 = mTouchEvents[0].points[1];
+
+ float firstDistance = GetDistance(firstPoint1, firstPoint2);
+ float currentDistance = GetDistance(currentPoint1, currentPoint2);
+ float distanceChanged = firstDistance - currentDistance;
+
+ // Check if distance has changed enough
+ if (fabsf(distanceChanged) > mMinimumDistanceDelta)
+ {
+ // Remove the first few events from the vector otherwise values are exaggerated
+ mTouchEvents.erase(mTouchEvents.begin(), mTouchEvents.end() - MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START);
+
+ if ( !mTouchEvents.empty() )
+ {
+ mStartingDistance = GetDistance(mTouchEvents.begin()->points[0], mTouchEvents.begin()->points[1]);
+
+ // Send pinch started
+ SendPinch(Gesture::Started, event);
+
+ mState = Started;
+ }
+
+ mTouchEvents.clear();
+ }
+
+ if (mState == Possible)
+ {
+ // No pinch, so restart detection
+ mState = Clear;
+ mTouchEvents.clear();
+ }
+ }
+ }
+ }
+ break;
+ }
+
+ case Started:
+ {
+ if (pointCount != 2)
+ {
+ // Send pinch finished event
+ SendPinch(Gesture::Finished, event);
+
+ mState = Clear;
+ mTouchEvents.clear();
+ }
+ else
+ {
+ const TouchPoint& currentPoint1 = event.points[0];
+ const TouchPoint& currentPoint2 = event.points[1];
+
+ if (currentPoint1.state == TouchPoint::Up || currentPoint2.state == TouchPoint::Up)
+ {
+ mTouchEvents.push_back(event);
+ // Send pinch finished event
+ SendPinch(Gesture::Finished, event);
+
+ mState = Clear;
+ mTouchEvents.clear();
+ }
+ else
+ {
+ mTouchEvents.push_back(event);
+
+ if (mTouchEvents.size() >= MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START)
+ {
+ // Send pinch continuing
+ SendPinch(Gesture::Continuing, event);
+
+ mTouchEvents.clear();
+ }
+ }
+ }
+ break;
+ }
+ }
+}
+
+void PinchGestureDetector::Update(const Integration::GestureRequest& request)
+{
+ // Nothing to do.
+}
+
+void PinchGestureDetector::SendPinch(Gesture::State state, const Integration::TouchEvent& currentEvent)
+{
+ Integration::PinchGestureEvent gesture(state);
+
+ if ( !mTouchEvents.empty() )
+ {
+ const Integration::TouchEvent& firstEvent = mTouchEvents[0];
+
+ // Assert if we have been holding TouchEvents that do not have 2 points
+ DALI_ASSERT_DEBUG( firstEvent.GetPointCount() == 2 );
+
+ // We should use the current event in our calculations unless it does not have two points.
+ // If it does not have two points, then we should use the last point in mTouchEvents.
+ Integration::TouchEvent event( currentEvent );
+ if ( event.GetPointCount() != 2 )
+ {
+ event = *mTouchEvents.rbegin();
+ }
+
+ const TouchPoint& firstPoint1( firstEvent.points[0] );
+ const TouchPoint& firstPoint2( firstEvent.points[1] );
+ const TouchPoint& currentPoint1( event.points[0] );
+ const TouchPoint& currentPoint2( event.points[1] );
+
+ float firstDistance = GetDistance(firstPoint1, firstPoint2);
+ float currentDistance = GetDistance(currentPoint1, currentPoint2);
+ gesture.scale = currentDistance / mStartingDistance;
+
+ float distanceDelta = fabsf(firstDistance - currentDistance);
+ unsigned long timeDelta = currentEvent.time - firstEvent.time;
+ gesture.speed = (distanceDelta / timeDelta) * 1000.0f;
+
+ gesture.centerPoint = GetCenterPoint(currentPoint1, currentPoint2);
+ }
+ else
+ {
+ // Something has gone wrong, just cancel the gesture.
+ gesture.state = Gesture::Cancelled;
+ }
+
+ gesture.time = currentEvent.time;
+
+ mCoreEventInterface.QueueCoreEvent(gesture);
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H__
+#define __DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
+
+// INTERNAL INCLUDES
+#include <events/gesture-detector.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+struct TouchEvent;
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class CoreEventInterface;
+
+/**
+ * When given a set of touch events, this detector attempts to determine if a pinch gesture has taken place.
+ */
+class PinchGestureDetector : public GestureDetector
+{
+public:
+
+ /**
+ * Constructor
+ * @param[in] coreEventInterface Used to send events to Core.
+ * @param[in] screenSize The size of the screen.
+ */
+ PinchGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, float minimumPinchDistance);
+
+ /**
+ * Virtual destructor.
+ */
+ virtual ~PinchGestureDetector();
+
+ /**
+ * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to
+ * trigger a pinch gesture
+ *
+ * @param[in] distance The minimum pinch distance in pixels
+ */
+ void SetMinimumPinchDistance(float distance);
+
+public:
+
+ /**
+ * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
+ */
+ virtual void SendEvent(const Integration::TouchEvent& event);
+
+ /**
+ * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
+ */
+ virtual void Update(const Integration::GestureRequest& request);
+
+private:
+
+ /**
+ * Emits the pinch gesture event to the core.
+ * @param[in] state The state of the pinch (whether it's starting, continuing or finished).
+ * @param[in] currentEvent The latest touch event.
+ */
+ void SendPinch(Gesture::State state, const Integration::TouchEvent& currentEvent);
+
+private:
+
+ /**
+ * Internal state machine.
+ */
+ enum State
+ {
+ Clear, ///< No gesture detected.
+ Possible, ///< The current touch event data suggests that a gesture is possible.
+ Started, ///< A gesture has been detected.
+ };
+
+ CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
+ State mState; ///< The current state of the detector.
+ std::vector<Integration::TouchEvent> mTouchEvents; ///< The touch events since initial touch down.
+
+ float mMinimumDistanceDelta; ///< The minimum distance before a pinch is applicable.
+
+ float mStartingDistance; ///< The distance between the two touch points when the pinch is first detected.
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "tap-gesture-detector.h"
+
+// EXTERNAL INCLUDES
+#include <cmath>
+
+#include <dali/public-api/events/touch-point.h>
+#include <dali/public-api/math/vector2.h>
+
+#include <dali/integration-api/events/gesture-requests.h>
+#include <dali/integration-api/events/tap-gesture-event.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <base/core-event-interface.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+// TODO: Set these according to DPI
+const float MAXIMUM_MOTION_ALLOWED = 20.0f;
+const unsigned long MAXIMUM_TIME_ALLOWED = 300u;
+} // unnamed namespace
+
+TapGestureDetector::TapGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::TapGestureRequest& request)
+: GestureDetector(screenSize, Gesture::Tap),
+ mCoreEventInterface(coreEventInterface),
+ mState(Clear),
+ mMinimumTapsRequired(request.minTaps),
+ mMaximumTapsRequired(request.maxTaps),
+ mTapsRegistered(0),
+ mTimerSlot( this )
+{
+ mTimer = Dali::Timer::New(MAXIMUM_TIME_ALLOWED);
+ mTimer.TickSignal().Connect( mTimerSlot, &TapGestureDetector::TimerCallback );
+}
+
+TapGestureDetector::~TapGestureDetector()
+{
+}
+
+void TapGestureDetector::SendEvent(const Integration::TouchEvent& event)
+{
+ if (event.GetPointCount() == 1)
+ {
+ const TouchPoint& point = event.points[0];
+ TouchPoint::State pointState = point.state;
+
+ switch (mState)
+ {
+ case Clear:
+ {
+ if (pointState == TouchPoint::Down)
+ {
+ mTouchPosition.x = point.screen.x;
+ mTouchPosition.y = point.screen.y;
+ mTouchTime = event.time;
+ mTapsRegistered = 0;
+ mState = Touched;
+ EmitGesture( Gesture::Possible, mTouchTime );
+ }
+ break;
+ }
+
+ case Touched:
+ {
+ Vector2 distanceDelta(abs(mTouchPosition.x - point.screen.x),
+ abs(mTouchPosition.y - point.screen.y));
+
+ unsigned long timeDelta = abs(event.time - mTouchTime);
+
+ if (distanceDelta.x > MAXIMUM_MOTION_ALLOWED ||
+ distanceDelta.y > MAXIMUM_MOTION_ALLOWED ||
+ timeDelta > MAXIMUM_TIME_ALLOWED)
+ {
+ // We may have already registered some taps so try emitting the gesture
+ EmitGesture( mTapsRegistered ? Gesture::Started : Gesture::Cancelled, event.time );
+ mState = (pointState == TouchPoint::Motion) ? Failed : Clear;
+ mTimer.Stop();
+ }
+
+ if (mState == Touched && pointState == TouchPoint::Up)
+ {
+ ++mTapsRegistered;
+
+ if (mTapsRegistered < mMaximumTapsRequired)
+ {
+ // Only emit gesture after timer expires if asked for multiple taps.
+ mState = Registered;
+ mTimer.Start();
+ }
+ else
+ {
+ EmitGesture(Gesture::Started, event.time);
+ mState = Clear;
+ mTimer.Stop();
+ }
+ }
+ break;
+ }
+
+ case Registered:
+ {
+ if (pointState == TouchPoint::Down)
+ {
+ mTimer.Stop();
+
+ Vector2 distanceDelta(abs(mTouchPosition.x - point.screen.x),
+ abs(mTouchPosition.y - point.screen.y));
+
+ // Check if subsequent tap is in a different position, if not then emit the previous tap
+ // count gesture (if required),
+ if (distanceDelta.x > MAXIMUM_MOTION_ALLOWED ||
+ distanceDelta.y > MAXIMUM_MOTION_ALLOWED)
+ {
+ EmitGesture(Gesture::Started, event.time);
+ mTouchPosition.x = point.screen.x;
+ mTouchPosition.y = point.screen.y;
+ }
+
+ mTouchTime = event.time;
+ mState = Touched;
+ mTimer.Start();
+ }
+ break;
+ }
+
+ case Failed:
+ {
+ if (pointState == TouchPoint::Up)
+ {
+ mState = Clear;
+ }
+ break;
+ }
+
+ default:
+ mState = Clear;
+ break;
+ }
+ }
+ else
+ {
+ mState = Failed;
+
+ // We have entered a multi-touch event so emit registered gestures if required.
+ EmitGesture(Gesture::Started, event.time);
+ }
+}
+
+void TapGestureDetector::Update(const Integration::GestureRequest& request)
+{
+ const Integration::TapGestureRequest& tap = static_cast<const Integration::TapGestureRequest&>(request);
+
+ mMinimumTapsRequired = tap.minTaps;
+ mMaximumTapsRequired = tap.maxTaps;
+}
+
+bool TapGestureDetector::TimerCallback()
+{
+ EmitGesture( ( mTapsRegistered >= mMinimumTapsRequired ? Gesture::Started : Gesture::Cancelled ), mTouchTime + MAXIMUM_TIME_ALLOWED);
+ mState = Clear;
+ return false;
+}
+
+void TapGestureDetector::EmitGesture( Gesture::State state, unsigned int time )
+{
+ if ( (state == Gesture::Possible) ||
+ (state == Gesture::Cancelled) ||
+ (mTapsRegistered >= mMinimumTapsRequired && mTapsRegistered <= mMaximumTapsRequired) )
+ {
+ Integration::TapGestureEvent event( state );
+ event.numberOfTaps = mTapsRegistered;
+ event.point = mTouchPosition;
+ event.time = time;
+
+ mCoreEventInterface.QueueCoreEvent(event);
+ }
+ mTapsRegistered = 0;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__
+#define __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
+#include <timer.h>
+
+// INTERNAL INCLUDES
+#include <events/gesture-detector.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+struct TouchEvent;
+struct TapGestureRequest;
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class CoreEventInterface;
+
+/**
+ * When given a set of touch events, this detector attempts to determine if a tap gesture has taken place.
+ */
+class TapGestureDetector : public GestureDetector
+{
+public:
+
+ /**
+ * Constructor
+ * @param[in] coreEventInterface Used to send events to Core.
+ * @param[in] screenSize The size of the screen.
+ * @param[in] request The tap gesture request.
+ */
+ TapGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::TapGestureRequest& request);
+
+ /**
+ * Virtual destructor.
+ */
+ virtual ~TapGestureDetector();
+
+public:
+
+ /**
+ * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
+ */
+ virtual void SendEvent(const Integration::TouchEvent& event);
+
+ /**
+ * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
+ */
+ virtual void Update(const Integration::GestureRequest& request);
+
+private:
+
+ /**
+ * Timer Callback
+ * @return will return false; one-shot timer.
+ */
+ bool TimerCallback();
+
+ /**
+ * Checks if registered taps are within required bounds and emits tap gesture if they are.
+ */
+ void EmitGesture( Gesture::State state, unsigned int time );
+
+private:
+
+ /**
+ * Internal state machine.
+ */
+ enum State
+ {
+ Clear, ///< No gesture detected.
+ Touched, ///< User is touching the screen.
+ Registered, ///< At least one tap has been registered.
+ Failed, ///< Gesture has failed.
+ };
+
+ CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
+ State mState; ///< Current state of the detector.
+
+ int mMinimumTapsRequired; ///< Minimum number of taps required.
+ int mMaximumTapsRequired; ///< Maximum number of taps required.
+ int mTapsRegistered; ///< In current detection, the number of taps registered.
+
+ Vector2 mTouchPosition; ///< The initial touch down position.
+ unsigned long mTouchTime; ///< The initial touch down time.
+
+ Dali::Timer mTimer; ///< The timer to start when we have registered the tap. We have to register all taps within a certain time frame.
+ SlotDelegate< TapGestureDetector > mTimerSlot;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__
--- /dev/null
+//******************************************************************************
+//
+// Default feedback theme for dali-toolkit
+//
+//******************************************************************************
+{
+ "style":
+ {
+ "PushButton":
+ {
+ "signals":
+ [
+ {
+ "type": "clicked",
+ "sound-feedback-pattern": "FEEDBACK_PATTERN_TAP"
+ }
+ ]
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <feedback/feedback-controller.h>
+
+// EXTERNAL INCLUDES
+#include <sstream>
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/json_parser.hpp>
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/object/object-registry.h>
+
+// INTERNAL INCLUDES
+#include <feedback/feedback-ids.h>
+#include <feedback/feedback-plugin-proxy.h>
+
+using std::string;
+using boost::property_tree::ptree;
+
+namespace // unnamed namespace
+{
+
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::General, false, "LOG_FEEDBACK_CONTROLLER");
+#endif
+
+const char* DEFAULT_FEEDBACK_THEME_PATH = DALI_FEEDBACK_THEME_DIR"default-feedback-theme.json";
+
+string LoadFile(const string& filename)
+{
+ DALI_ASSERT_DEBUG( 0 != filename.length());
+
+ string contents;
+
+ std::filebuf buf;
+ buf.open(filename.c_str(), std::ios::in);
+ if( buf.is_open() )
+ {
+ std::istream stream(&buf);
+
+ // determine data length
+ stream.seekg(0, std::ios_base::end);
+ unsigned int length = static_cast<unsigned int>( stream.tellg() );
+ stream.seekg(0, std::ios_base::beg);
+
+ // allocate a buffer
+ contents.resize(length);
+ // read data into buffer
+ stream.read(&contents[0], length);
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceLoader::LoadFile(%s) - loaded %d bytes\n", filename.c_str(), length );
+ }
+ else
+ {
+ DALI_LOG_ERROR("ResourceLoader::LoadFile(%s) - failed to load\n", filename.c_str());
+ }
+
+ return contents;
+}
+
+static string FindFilename( const ptree& child )
+{
+ boost::optional<string> filename = child.get_optional<string>( "filename" );
+ DALI_ASSERT_ALWAYS( filename && "Filename definiton must have 'filename'" );
+
+ struct stat buf;
+
+ if( 0 == stat( (*filename).c_str(), &buf) )
+ {
+ return *filename;
+ }
+
+ // else not found
+ return "";
+}
+
+} // unnamed namespace
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+struct SignalFeedbackInfo
+{
+ /**
+ * Default constructor.
+ * @deprecated - moved into dali-adaptor FeedbackController.
+ */
+ SignalFeedbackInfo()
+ :mHasHapticFeedbackInfo(false),
+ mHasSoundFeedbackInfo(false)
+ {
+ }
+
+ string mSignalName;
+ bool mHasHapticFeedbackInfo;
+ bool mHasSoundFeedbackInfo;
+ string mHapticFeedbackPattern;
+ string mSoundFeedbackPattern;
+ string mHapticFeedbackFile;
+ string mSoundFeedbackFile;
+};
+
+typedef std::vector<SignalFeedbackInfo> SignalFeedbackInfoContainer;
+typedef SignalFeedbackInfoContainer::const_iterator SignalFeedbackInfoConstIter;
+
+struct FeedbackStyleInfo
+{
+ /**
+ * Default constructor.
+ * @deprecated - moved into dali-adaptor FeedbackController.
+ */
+ FeedbackStyleInfo()
+ {
+ }
+
+ string mTypeName;
+ std::vector<SignalFeedbackInfo> mSignalFeedbackInfoList;
+};
+
+static const FeedbackStyleInfo DEFAULT_FEEDBACK_STYLE_INFO;
+
+FeedbackController::FeedbackController( FeedbackPluginProxy& plugin )
+: mPlugin( plugin ),
+ mConnections( this )
+{
+ string defaultTheme = LoadFile( DEFAULT_FEEDBACK_THEME_PATH );
+ LoadTheme( defaultTheme );
+
+ Dali::ObjectRegistry registry = Dali::Stage::GetCurrent().GetObjectRegistry();
+
+ registry.ObjectCreatedSignal().Connect( mConnections, &FeedbackController::ObjectCreatedCallback );
+
+ Dali::StyleMonitor styleMonitor( Dali::StyleMonitor::Get() );
+ DALI_ASSERT_DEBUG( styleMonitor && "StyleMonitor not available" );
+ styleMonitor.StyleChangeSignal().Connect( mConnections, &FeedbackController::StyleChangedCallback );
+}
+
+FeedbackController::~FeedbackController()
+{
+}
+
+struct PlayFeedbackFromSignal
+{
+ PlayFeedbackFromSignal( FeedbackController& controller, const string& typeName, const string& signalName )
+ : mController( controller ),
+ mTypeName( typeName ),
+ mSignalName( signalName )
+ {
+ }
+
+ void operator()()
+ {
+ mController.PlayFeedback( mTypeName, mSignalName );
+ }
+
+ FeedbackController& mController;
+ string mTypeName;
+ string mSignalName;
+};
+
+void FeedbackController::ObjectCreatedCallback( BaseHandle handle )
+{
+ if( handle )
+ {
+ string type = handle.GetTypeName();
+
+ const FeedbackStyleInfo styleInfo = GetStyleInfo( type );
+
+ for( SignalFeedbackInfoConstIter iter = styleInfo.mSignalFeedbackInfoList.begin(); iter != styleInfo.mSignalFeedbackInfoList.end(); ++iter )
+ {
+ const SignalFeedbackInfo& info = *iter;
+
+ if( info.mHasHapticFeedbackInfo || info.mHasSoundFeedbackInfo )
+ {
+ if( !info.mHapticFeedbackPattern.empty() || !info.mHapticFeedbackFile.empty() ||
+ !info.mSoundFeedbackPattern.empty() || !info.mSoundFeedbackFile.empty() )
+ {
+ handle.ConnectSignal( this,
+ info.mSignalName,
+ PlayFeedbackFromSignal( *this, type, info.mSignalName ) );
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FeedbackController::ObjectCreatedCallback found Haptic pattern %s for Object type: %s, Signal Type: %s\n",
+ info.mHapticFeedbackPattern.c_str(), type.c_str(), info.mSignalName.c_str() );
+ }
+ else
+ {
+ DALI_LOG_ERROR("FeedbackController::ObjectCreatedCallback() Warning Inconsistent data in theme file!\n");
+ }
+ }
+ }
+ }
+}
+
+const FeedbackStyleInfo& FeedbackController::GetStyleInfo( const string& type ) const
+{
+ std::map<const string, FeedbackStyleInfo>::const_iterator iter( mStyleInfoLut.find( type ) );
+ if( iter != mStyleInfoLut.end() )
+ {
+ return iter->second;
+ }
+ else
+ {
+ return DEFAULT_FEEDBACK_STYLE_INFO;
+ }
+}
+
+void FeedbackController::StyleChangedCallback( Dali::StyleMonitor styleMonitor, Dali::StyleChange styleChange )
+{
+ if( styleChange.themeChange )
+ {
+ const string& userDefinedThemePath = styleChange.themeFilePath;
+ const string& userDefinedTheme = LoadFile( userDefinedThemePath );
+
+ if( !LoadTheme( userDefinedTheme ) )
+ {
+ DALI_LOG_ERROR("FeedbackController::StyleChangedCallback() User defined theme failed to load! \n");
+
+ //If there is any problem is using the user defined theme, then fall back to default theme
+ if( !LoadTheme( DEFAULT_FEEDBACK_THEME_PATH ) )
+ {
+ //If the default theme fails, Then No luck!
+ DALI_LOG_ERROR("FeedbackController::StyleChangedCallback() Default theme failed to load! \n");
+ }
+ }
+ }
+}
+
+bool FeedbackController::LoadTheme( const string& data )
+{
+ bool result = false;
+
+ try
+ {
+ LoadFromString( data );
+
+ result = true;
+ }
+ catch(...)
+ {
+ //Problem in user set theme, So fallback to use default theme.
+ DALI_LOG_ERROR( "FeedbackController::LoadTheme() Failed to load theme\n" );
+ }
+
+ return result;
+}
+
+void FeedbackController::LoadFromString( const string& data )
+{
+ std::stringstream jsonData( data );
+
+ ptree node;
+
+ try
+ {
+ // tree root is cleared each read_json
+ boost::property_tree::json_parser::read_json( jsonData, node );
+ }
+ catch( boost::property_tree::json_parser::json_parser_error& error )
+ {
+ DALI_LOG_WARNING( "JSON Parse Error:'%s'\n", error.message().c_str() );
+ DALI_LOG_WARNING( "JSON Parse File :'%s'\n", error.filename().c_str() );
+ DALI_LOG_WARNING( "JSON Parse Line :'%d'\n", error.line() );
+ throw;
+ }
+ catch(...)
+ {
+ throw;
+ }
+
+ // Clear previously loaded style
+
+ mSoundFilesLut.clear();
+ mHapticFilesLut.clear();
+ mStyleInfoLut.clear();
+
+ // Parse filenames
+
+ if ( node.get_child_optional("sounds") )
+ {
+ const ptree& soundsNode = node.get_child( "sounds" );
+ const ptree::const_iterator endSoundsIter = soundsNode.end();
+ for( ptree::const_iterator iter = soundsNode.begin(); endSoundsIter != iter; ++iter )
+ {
+ const ptree::value_type& keyChild = *iter;
+
+ string key( keyChild.first );
+
+ boost::optional<string> name( keyChild.second.get_optional<string>("filename") );
+ if( name )
+ {
+ string fileName( FindFilename( keyChild.second ) );
+
+ mSoundFilesLut.insert( std::pair<const string, const string>(key, fileName) );
+ }
+ else
+ {
+ DALI_LOG_WARNING("Invalid sound file\n");
+ }
+ }
+ }
+
+ if ( node.get_child_optional("haptic") )
+ {
+ const ptree& hapticNode = node.get_child( "haptic" );
+ const ptree::const_iterator endHapticIter = hapticNode.end();
+ for( ptree::const_iterator iter = hapticNode.begin(); endHapticIter != iter; ++iter )
+ {
+ const ptree::value_type& keyChild = *iter;
+
+ string key( keyChild.first );
+
+ boost::optional<string> name( keyChild.second.get_optional<string>("filename") );
+ if( name )
+ {
+ string fileName( FindFilename( keyChild.second ) );
+
+ mHapticFilesLut.insert( std::pair<const string, const string>(key, fileName) );
+ }
+ else
+ {
+ DALI_LOG_WARNING("Invalid haptic file\n");
+ }
+ }
+ }
+
+ // Parse style
+
+ const ptree& styleNode = node.get_child( "style" );
+ const ptree::const_iterator endIter = styleNode.end();
+ for( ptree::const_iterator iter = styleNode.begin(); endIter != iter; ++iter )
+ {
+ const ptree::value_type& keyChild = *iter;
+
+ string key( keyChild.first );
+ FeedbackStyleInfo themeInfo;
+ themeInfo.mTypeName = key;
+
+ const ptree& signalsNode = keyChild.second.get_child( "signals" );
+ const ptree::const_iterator endIter = signalsNode.end();
+ for( ptree::const_iterator iter = signalsNode.begin(); endIter != iter; ++iter )
+ {
+ const ptree::value_type& signal_child = *iter;
+
+ SignalFeedbackInfo signalFeedbackInfo;
+
+ boost::optional<string> type( signal_child.second.get_optional<string>( "type" ) );
+ DALI_ASSERT_ALWAYS( type && "Signal must have a type" );
+
+ signalFeedbackInfo.mSignalName = *type;
+
+ boost::optional<string> hapticFeedbackPattern( signal_child.second.get_optional<string>( "haptic-feedback-pattern" ) );
+ if( hapticFeedbackPattern )
+ {
+ signalFeedbackInfo.mHasHapticFeedbackInfo = true;
+ signalFeedbackInfo.mHapticFeedbackPattern = *hapticFeedbackPattern;
+ }
+
+ boost::optional<string> hapticFeedbackFile( signal_child.second.get_optional<string>( "haptic-feedback-file" ) );
+ if( hapticFeedbackFile )
+ {
+ signalFeedbackInfo.mHasHapticFeedbackInfo = true;
+ signalFeedbackInfo.mHapticFeedbackFile = GetHapticPath( *hapticFeedbackFile );
+ }
+
+ boost::optional<string> soundFeedbackPattern( signal_child.second.get_optional<string>( "sound-feedback-pattern" ) );
+ if( soundFeedbackPattern )
+ {
+ signalFeedbackInfo.mHasSoundFeedbackInfo = true;
+ signalFeedbackInfo.mSoundFeedbackPattern = *soundFeedbackPattern;
+ }
+
+ boost::optional<string> soundFeedbackFile( signal_child.second.get_optional<string>( "sound-feedback-file" ) );
+ if( soundFeedbackFile )
+ {
+ signalFeedbackInfo.mHasSoundFeedbackInfo = true;
+ signalFeedbackInfo.mSoundFeedbackFile = GetSoundPath( *soundFeedbackFile );
+ }
+
+ if( signalFeedbackInfo.mHasHapticFeedbackInfo || signalFeedbackInfo.mHasSoundFeedbackInfo )
+ {
+ AddSignalInfo( themeInfo, signalFeedbackInfo );
+ }
+ }
+
+ mStyleInfoLut[key] = themeInfo;
+ }
+}
+
+void FeedbackController::AddSignalInfo( FeedbackStyleInfo& styleInfo, SignalFeedbackInfo signalInfo )
+{
+ bool updated = false;
+ std::vector<SignalFeedbackInfo>::iterator iter;
+
+ // If info exists for the signal then update it, else add new
+ for( iter = styleInfo.mSignalFeedbackInfoList.begin(); iter != styleInfo.mSignalFeedbackInfoList.end(); ++iter )
+ {
+ if( (*iter).mSignalName == signalInfo.mSignalName )
+ {
+ (*iter).mHasHapticFeedbackInfo = signalInfo.mHasHapticFeedbackInfo;
+ (*iter).mHapticFeedbackPattern = signalInfo.mHapticFeedbackPattern;
+ (*iter).mHapticFeedbackFile = signalInfo.mHapticFeedbackFile;
+ (*iter).mHasSoundFeedbackInfo = signalInfo.mHasSoundFeedbackInfo;
+ (*iter).mSoundFeedbackPattern = signalInfo.mSoundFeedbackPattern;
+ (*iter).mSoundFeedbackFile = signalInfo.mSoundFeedbackFile;
+
+ updated = true;
+ break;
+ }
+ }
+
+ if( !updated )
+ {
+ styleInfo.mSignalFeedbackInfoList.push_back( signalInfo );
+ }
+}
+
+string FeedbackController::GetSoundPath( const string& key ) const
+{
+ std::map<const string, const string>::const_iterator iter( mSoundFilesLut.find( key ) );
+ string path;
+ if( iter != mSoundFilesLut.end() )
+ {
+ path = iter->second;
+ }
+ else
+ {
+ DALI_LOG_WARNING( "Request for sound file '%s' failed\n", key.c_str() );
+ DALI_ASSERT_ALWAYS( !"Sound file does not exist" );
+ }
+ return path;
+}
+
+string FeedbackController::GetHapticPath( const string& key ) const
+{
+ std::map<const string, const string>::const_iterator iter( mHapticFilesLut.find( key ) );
+ string path;
+ if( iter != mHapticFilesLut.end() )
+ {
+ path = iter->second;
+ }
+ else
+ {
+ DALI_LOG_WARNING( "Request for haptic file '%s' failed\n", key.c_str() );
+ DALI_ASSERT_ALWAYS( !"Haptic file does not exist" );
+ }
+ return path;
+}
+
+void FeedbackController::PlayFeedback(const string& type, const string& signalName)
+{
+ const FeedbackStyleInfo styleInfo = GetStyleInfo(type);
+ SignalFeedbackInfoConstIter iter;
+
+ for(iter = styleInfo.mSignalFeedbackInfoList.begin(); iter != styleInfo.mSignalFeedbackInfoList.end(); ++iter)
+ {
+ const SignalFeedbackInfo& info = *iter;
+
+ if(info.mSignalName == signalName)
+ {
+ if(info.mHasHapticFeedbackInfo)
+ {
+ if(!info.mHapticFeedbackPattern.empty())
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FeedbackController::PlayFeedback Playing Haptic effect: Object type: %s, Signal type: %s, pattern type: %s\n",
+ type.c_str(), signalName.c_str(), info.mHapticFeedbackPattern.c_str());
+
+ mPlugin.PlayFeedbackPattern( FEEDBACK_TYPE_VIBRATION, GetFeedbackPattern(info.mHapticFeedbackPattern) );
+ }
+ else if(!info.mHapticFeedbackFile.empty())
+ {
+ mPlugin.PlayHaptic( info.mHapticFeedbackFile );
+ }
+ }
+
+ if(info.mHasSoundFeedbackInfo)
+ {
+ if(!info.mSoundFeedbackPattern.empty())
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FeedbackController::PlayFeedback Playing Sound effect: Object type: %s, Signal type: %s, pattern type: %s\n",
+ type.c_str(), signalName.c_str(), info.mHapticFeedbackPattern.c_str());
+
+ mPlugin.PlayFeedbackPattern( FEEDBACK_TYPE_SOUND, GetFeedbackPattern(info.mSoundFeedbackPattern) );
+ }
+ else if(!info.mSoundFeedbackFile.empty())
+ {
+ mPlugin.PlaySound( info.mSoundFeedbackFile );
+ }
+ }
+
+ break;
+ }
+ }
+}
+
+FeedbackPattern FeedbackController::GetFeedbackPattern( const string &pattern )
+{
+ if( 0 == mFeedbackPatternLut.size() )
+ {
+ mFeedbackPatternLut["FEEDBACK_PATTERN_NONE"] = Dali::FEEDBACK_PATTERN_NONE;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_TAP"] = Dali::FEEDBACK_PATTERN_TAP;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_SIP"] = Dali::FEEDBACK_PATTERN_SIP;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_SIP_BACKSPACE"] = Dali::FEEDBACK_PATTERN_SIP_BACKSPACE;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_MAX_CHARACTER"] = Dali::FEEDBACK_PATTERN_MAX_CHARACTER;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY0"] = Dali::FEEDBACK_PATTERN_KEY0;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY1"] = Dali::FEEDBACK_PATTERN_KEY1;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY2"] = Dali::FEEDBACK_PATTERN_KEY2;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY3"] = Dali::FEEDBACK_PATTERN_KEY3;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY4"] = Dali::FEEDBACK_PATTERN_KEY4;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY5"] = Dali::FEEDBACK_PATTERN_KEY5;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY6"] = Dali::FEEDBACK_PATTERN_KEY6;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY7"] = Dali::FEEDBACK_PATTERN_KEY7;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY8"] = Dali::FEEDBACK_PATTERN_KEY8;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY9"] = Dali::FEEDBACK_PATTERN_KEY9;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY_STAR"] = Dali::FEEDBACK_PATTERN_KEY_STAR;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_KEY_SHARP"] = Dali::FEEDBACK_PATTERN_KEY_SHARP;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_HOLD"] = Dali::FEEDBACK_PATTERN_HOLD;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_MULTI_TAP"] = Dali::FEEDBACK_PATTERN_MULTI_TAP;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_HW_TAP"] = Dali::FEEDBACK_PATTERN_HW_TAP;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_HW_HOLD"] = Dali::FEEDBACK_PATTERN_HW_HOLD;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_MESSAGE"] = Dali::FEEDBACK_PATTERN_MESSAGE;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_MESSAGE_ON_CALL"] = Dali::FEEDBACK_PATTERN_MESSAGE_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_EMAIL"] = Dali::FEEDBACK_PATTERN_EMAIL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_EMAIL_ON_CALL"] = Dali::FEEDBACK_PATTERN_EMAIL_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_WAKEUP"] = Dali::FEEDBACK_PATTERN_WAKEUP;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_WAKEUP_ON_CALL"] = Dali::FEEDBACK_PATTERN_WAKEUP_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_SCHEDULE"] = Dali::FEEDBACK_PATTERN_SCHEDULE;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_SCHEDULE_ON_CALL"] = Dali::FEEDBACK_PATTERN_SCHEDULE_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_TIMER"] = Dali::FEEDBACK_PATTERN_TIMER;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_TIMER_ON_CALL"] = Dali::FEEDBACK_PATTERN_TIMER_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_GENERAL"] = Dali::FEEDBACK_PATTERN_GENERAL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_GENERAL_ON_CALL"] = Dali::FEEDBACK_PATTERN_GENERAL_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_POWERON"] = Dali::FEEDBACK_PATTERN_POWERON;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_POWEROFF"] = Dali::FEEDBACK_PATTERN_POWEROFF;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_CHARGERCONN"] = Dali::FEEDBACK_PATTERN_CHARGERCONN;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_CHARGERCONN_ON_CALL"] = Dali::FEEDBACK_PATTERN_CHARGERCONN_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_FULLCHARGED"] = Dali::FEEDBACK_PATTERN_FULLCHARGED;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_FULLCHARGED_ON_CALL"] = Dali::FEEDBACK_PATTERN_FULLCHARGED_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_LOWBATT"] = Dali::FEEDBACK_PATTERN_LOWBATT;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_LOWBATT_ON_CALL"] = Dali::FEEDBACK_PATTERN_LOWBATT_ON_CALL;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_LOCK"] = Dali::FEEDBACK_PATTERN_LOCK;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_UNLOCK"] = Dali::FEEDBACK_PATTERN_UNLOCK;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_CALLCONNECT"] = Dali::FEEDBACK_PATTERN_CALLCONNECT;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_DISCALLCONNECT"] = Dali::FEEDBACK_PATTERN_DISCALLCONNECT;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_MINUTEMINDER"] = Dali::FEEDBACK_PATTERN_MINUTEMINDER;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_VIBRATION"] = Dali::FEEDBACK_PATTERN_VIBRATION;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_SHUTTER"] = Dali::FEEDBACK_PATTERN_SHUTTER;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_LIST_REORDER"] = Dali::FEEDBACK_PATTERN_LIST_REORDER;
+ mFeedbackPatternLut["FEEDBACK_PATTERN_SLIDER_SWEEP"] = Dali::FEEDBACK_PATTERN_SLIDER_SWEEP;
+ }
+
+ std::map<const string, FeedbackPattern>::const_iterator iter( mFeedbackPatternLut.find( pattern ) );
+
+ if( iter != mFeedbackPatternLut.end() )
+ {
+ return iter->second;
+ }
+ else
+ {
+ DALI_LOG_ERROR( "Unknown feedback pattern type: %s, So Defaulting to FEEDBACK_PATTERN_NONE!\n" );
+ return Dali::FEEDBACK_PATTERN_NONE;
+ }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_FEEDBACK_CONTROLLER_H__
+#define __DALI_INTERNAL_FEEDBACK_CONTROLLER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <map>
+#include <dali/public-api/object/base-handle.h>
+#include <style-monitor.h>
+
+// INTERNAL INCLUDES
+#include <feedback-plugin.h>
+#include <feedback/feedback-ids.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+struct FeedbackStyleInfo;
+struct SignalFeedbackInfo;
+
+class FeedbackPluginProxy;
+
+/**
+ * Plays feedback effects for Dali-Toolkit UI Controls.
+ */
+class FeedbackController : public ConnectionTracker
+{
+public:
+
+ /**
+ * Constructor.
+ */
+ FeedbackController( FeedbackPluginProxy& plugin );
+
+ /**
+ * The destructor
+ */
+ ~FeedbackController();
+
+ /**
+ * Called to start playing feedback effects.
+ */
+ void Start();
+
+ /**
+ * Called to stop playing feedback effects.
+ */
+ void Stop();
+
+ /**
+ * Callback function to play a feedback effect when a signal is emitted for an object
+ * Plays feedback effect.
+ * @param [in] type The Object type
+ * @param [in] signalName The name of the signal
+ */
+ void PlayFeedback(const std::string& type, const std::string& signalName);
+
+private:
+
+ /**
+ * UI string data format
+ */
+ enum UIFormat
+ {
+ JSON, ///< String is JSON
+ };
+
+ /**
+ * Callback function for Dali::ObjectRegistry::SignalObjectCreated signal
+ * @param [in] object Handle to the newly created object
+ */
+ void ObjectCreatedCallback( BaseHandle object );
+
+ /**
+ * Helper to retrieve styleInfo from mStyleInfoLut
+ * @param type A string described a type of object
+ * @return The style information for the given object
+ */
+ const FeedbackStyleInfo& GetStyleInfo( const std::string& type) const;
+
+ /**
+ * Callback function for Dali::ObjectRegistry::SignalObjectCreated signal
+ * @param [in] object Handle to the newly created object
+ */
+ void StyleChangedCallback(Dali::StyleMonitor styleMonitor, StyleChange styleChange);
+
+ /**
+ * Callback function for Dali::Toolkit::PushButton::SignalPressed signal
+ * Plays feedback effect.
+ * @param [in] effect The feedback effect to play
+ */
+ bool LoadTheme(const std::string& data);
+
+ /**
+ * Loads a string representation the theme.
+ * @param [in] data A string represenation of the theme.
+ * @param [in] format The string representation format ie JSON.
+ */
+ void LoadFromString( const std::string& data );
+
+ /**
+ * Helper to store signal information.
+ * @param [in] styleInfo The information will be stored here.
+ * @param [in] signalInfo The information to add.
+ */
+ void AddSignalInfo( FeedbackStyleInfo& styleInfo, SignalFeedbackInfo signalInfo );
+
+ /**
+ * Helper to retrieve the path to a sound file.
+ * @param[in] key A string which identifies the path.
+ * @return The path.
+ */
+ std::string GetSoundPath( const std::string& key ) const;
+
+ /**
+ * Helper to retrieve the path to a haptic file.
+ * @param[in] key A string which identifies the path.
+ * @return The path.
+ */
+ std::string GetHapticPath( const std::string& key ) const;
+
+ /**
+ * Map a pattern string to feedback pattern ID.
+ * @param [in] pattern The pattern string.
+ * @return A feedback pattern ID.
+ */
+ FeedbackPattern GetFeedbackPattern( const std::string& pattern );
+
+ /**
+ * Plays a feedback effect
+ * @param [in] type The feedback type haptic or sound
+ * @param [in] effect The feedback effect to play
+ */
+ void PlayEffect(FeedbackType type, FeedbackPattern effect);
+
+ /**
+ * Plays a haptic or sound effect file
+ * @param [in] type The feedback type haptic or sound
+ * @param [in] file The path to the file containing the effect
+ */
+ void PlayFile(FeedbackType type, const std::string& file);
+
+private:
+
+ FeedbackPluginProxy& mPlugin;
+
+ std::map<const std::string, FeedbackPattern> mFeedbackPatternLut; ///< Used to convert feedback pattern strings into enumerated values
+ std::map<const std::string, const std::string> mSoundFilesLut; ///< Converts key strings into sound file paths
+ std::map<const std::string, const std::string> mHapticFilesLut; ///< Converts key strings into haptic file paths
+ std::map<const std::string, FeedbackStyleInfo> mStyleInfoLut; ///< Converts key strings into style information
+
+ SlotDelegate< FeedbackController > mConnections; ///< Maintains the connections to the Object registry.
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_FEEDBACK_CONTROLLER_H__
--- /dev/null
+#ifndef __DALI_FEEDBACK_IDS_H__
+#define __DALI_FEEDBACK_IDS_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+
+/**
+ * Enumerations for the types of feedback
+ * Note: These are based on feedback_type_e in libsvi
+ */
+enum FeedbackType
+{
+ FEEDBACK_TYPE_NONE,
+
+ FEEDBACK_TYPE_SOUND,
+ FEEDBACK_TYPE_VIBRATION,
+ FEEDBACK_TYPE_LED,
+
+ FEEDBACK_TYPE_END
+};
+
+/**
+ * The pattern list for feedback effects.
+ * Note: These are based on feedback_pattern_e in libsvi
+ */
+enum FeedbackPattern
+{
+ FEEDBACK_PATTERN_NONE = -1,
+
+ FEEDBACK_PATTERN_TAP = 0, /**< feedback pattern when general touch */
+ FEEDBACK_PATTERN_SIP, /**< feedback pattern when touch text key */
+ FEEDBACK_PATTERN_SIP_BACKSPACE, /**< feedback pattern when touch backspace key */
+ FEEDBACK_PATTERN_MAX_CHARACTER, /**< feedback pattern when max character */
+ FEEDBACK_PATTERN_KEY0, /**< feedback pattern when touch numeric 0 key */
+ FEEDBACK_PATTERN_KEY1, /**< feedback pattern when touch numeric 1 key */
+ FEEDBACK_PATTERN_KEY2, /**< feedback pattern when touch numeric 2 key */
+ FEEDBACK_PATTERN_KEY3, /**< feedback pattern when touch numeric 3 key */
+ FEEDBACK_PATTERN_KEY4, /**< feedback pattern when touch numeric 4 key */
+ FEEDBACK_PATTERN_KEY5, /**< feedback pattern when touch numeric 5 key */
+ FEEDBACK_PATTERN_KEY6, /**< feedback pattern when touch numeric 6 key */
+ FEEDBACK_PATTERN_KEY7, /**< feedback pattern when touch numeric 7 key */
+ FEEDBACK_PATTERN_KEY8, /**< feedback pattern when touch numeric 8 key */
+ FEEDBACK_PATTERN_KEY9, /**< feedback pattern when touch numeric 9 key */
+ FEEDBACK_PATTERN_KEY_STAR, /**< feedback pattern when touch star key */
+ FEEDBACK_PATTERN_KEY_SHARP, /**< feedback pattern when touch sharp key */
+ FEEDBACK_PATTERN_HOLD, /**< feedback pattern when touch hold */
+ FEEDBACK_PATTERN_MULTI_TAP, /**< feedback pattern when multi touch */
+ FEEDBACK_PATTERN_HW_TAP, /**< feedback pattern when press hardware key */
+ FEEDBACK_PATTERN_HW_HOLD, /**< feedback pattern when holding press hardware key */
+
+ FEEDBACK_PATTERN_MESSAGE, /**< feedback pattern when incoming a message */
+ FEEDBACK_PATTERN_MESSAGE_ON_CALL, /**< feedback pattern when incoming a message on call */
+ FEEDBACK_PATTERN_EMAIL, /**< feedback pattern when incoming an email */
+ FEEDBACK_PATTERN_EMAIL_ON_CALL, /**< feedback pattern when incoming an email on call */
+ FEEDBACK_PATTERN_WAKEUP, /**< feedback pattern when alert wake up call */
+ FEEDBACK_PATTERN_WAKEUP_ON_CALL, /**< feedback pattern when alert wake up call on call */
+ FEEDBACK_PATTERN_SCHEDULE, /**< feedback pattern when alert schedule alarm */
+ FEEDBACK_PATTERN_SCHEDULE_ON_CALL, /**< feedback pattern when alert schedule alarm on call */
+ FEEDBACK_PATTERN_TIMER, /**< feedback pattern when alert timer */
+ FEEDBACK_PATTERN_TIMER_ON_CALL, /**< feedback pattern when alert timer on call */
+ FEEDBACK_PATTERN_GENERAL, /**< feedback pattern when alert general event */
+ FEEDBACK_PATTERN_GENERAL_ON_CALL, /**< feedback pattern when alert general event on call */
+
+ FEEDBACK_PATTERN_POWERON, /**< feedback pattern when power on */
+ FEEDBACK_PATTERN_POWEROFF, /**< feedback pattern when power off */
+ FEEDBACK_PATTERN_CHARGERCONN, /**< feedback pattern when connecting charger */
+ FEEDBACK_PATTERN_CHARGERCONN_ON_CALL, /**< feedback pattern when connecting charger on call */
+ FEEDBACK_PATTERN_FULLCHARGED, /**< feedback pattern when full charged */
+ FEEDBACK_PATTERN_FULLCHARGED_ON_CALL, /**< feedback pattern when full charged on call */
+ FEEDBACK_PATTERN_LOWBATT, /**< feedback pattern when low battery */
+ FEEDBACK_PATTERN_LOWBATT_ON_CALL, /**< feedback pattern when low battery on call */
+ FEEDBACK_PATTERN_LOCK, /**< feedback pattern when lock */
+ FEEDBACK_PATTERN_UNLOCK, /**< feedback pattern when unlock */
+ FEEDBACK_PATTERN_CALLCONNECT, /**< feedback pattern when connecting call */
+ FEEDBACK_PATTERN_DISCALLCONNECT, /**< feedback pattern when disconnecting call */
+ FEEDBACK_PATTERN_MINUTEMINDER, /**< feedback pattern when minute minder */
+ FEEDBACK_PATTERN_VIBRATION, /**< feedback pattern when vibration */
+ FEEDBACK_PATTERN_SHUTTER, /**< feedback pattern when screen capture or camera shutter */
+ FEEDBACK_PATTERN_LIST_REORDER, /**< feedback pattern when list reorder */
+ FEEDBACK_PATTERN_SLIDER_SWEEP, /**< feedback pattern when slider sweep */
+
+ FEEDBACK_PATTERN_END,
+};
+
+
+} // namespace Dali
+
+#endif // __DALI_FEEDBACK_IDS_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <feedback/feedback-plugin-proxy.h>
+
+// EXTERNAL INCLUDES
+#include <dlfcn.h>
+#include <dali/integration-api/debug.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+const char * const FeedbackPluginProxy::DEFAULT_OBJECT_NAME( "libdali-feedback-plugin.so" );
+
+FeedbackPluginProxy::FeedbackPluginProxy( const std::string& sharedObjectName )
+: mInitializeAttempted( false ),
+ mLibHandle( NULL ),
+ mSharedObjectName( sharedObjectName ),
+ mCreatePluginFunctionPtr( NULL ),
+ mFeedbackPlugin( NULL )
+{
+ // Lazily initialize when sound/haptic is first played
+}
+
+FeedbackPluginProxy::~FeedbackPluginProxy()
+{
+ if( mFeedbackPlugin )
+ {
+ delete mFeedbackPlugin;
+ mFeedbackPlugin = NULL;
+
+ DALI_ASSERT_ALWAYS( mLibHandle );
+ if( dlclose( mLibHandle ) )
+ {
+ DALI_LOG_ERROR( "Error closing dali feedback plugin library: %s\n", dlerror() );
+ }
+ }
+}
+
+void FeedbackPluginProxy::PlayHaptic( const std::string& filePath )
+{
+ // Lazy initialization
+ Initialize();
+
+ if( mFeedbackPlugin )
+ {
+ mFeedbackPlugin->PlayHaptic( filePath );
+ }
+}
+
+void FeedbackPluginProxy::PlayHapticMonotone( unsigned int duration )
+{
+ // Lazy initialization
+ Initialize();
+
+ if( mFeedbackPlugin )
+ {
+ mFeedbackPlugin->PlayHapticMonotone( duration );
+ }
+}
+
+void FeedbackPluginProxy::StopHaptic()
+{
+ // Must already have been initialized to play haptic
+ if( mFeedbackPlugin )
+ {
+ mFeedbackPlugin->StopHaptic();
+ }
+}
+
+int FeedbackPluginProxy::PlaySound( const std::string& fileName )
+{
+ // Lazy initialization
+ Initialize();
+
+ if( mFeedbackPlugin )
+ {
+ return mFeedbackPlugin->PlaySound( fileName );
+ }
+
+ return 0;
+}
+
+void FeedbackPluginProxy::StopSound( int handle )
+{
+ // Must already have been initialized to play sound
+ if ( mFeedbackPlugin )
+ {
+ mFeedbackPlugin->StopSound( handle );
+ }
+}
+
+void FeedbackPluginProxy::PlayFeedbackPattern( int type, int pattern )
+{
+ // Lazy initialization
+ Initialize();
+
+ if( mFeedbackPlugin )
+ {
+ mFeedbackPlugin->PlayFeedbackPattern( type, pattern );
+ }
+}
+
+void FeedbackPluginProxy::Initialize()
+{
+ // Only attempt to load dll once
+ if ( !mInitializeAttempted )
+ {
+ mInitializeAttempted = true;
+
+ mLibHandle = dlopen( mSharedObjectName.c_str(), RTLD_NOW | RTLD_GLOBAL );
+ if( !mLibHandle )
+ {
+ DALI_LOG_ERROR( "Cannot load dali feedback plugin library error: %s\n", dlerror() );
+ return;
+ }
+
+ // reset errors
+ dlerror();
+
+ // load plugin
+ mCreatePluginFunctionPtr = reinterpret_cast<CreateFeedbackPlugin*>(dlsym(mLibHandle, "CreateFeedbackPlugin"));
+ if(!mCreatePluginFunctionPtr)
+ {
+ DALI_LOG_ERROR("Cannot load symbol CreateFeedbackPlugin(): %s\n", dlerror());
+ return;
+ }
+
+ // reset errors
+ dlerror();
+
+ mFeedbackPlugin = mCreatePluginFunctionPtr();
+
+ if(!mFeedbackPlugin)
+ {
+ DALI_LOG_ERROR("Call to function CreateFeedbackPlugin() failed\n");
+ }
+ }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_FEEDBACK_PLUGIN_PROXY_H__
+#define __DALI_INTERNAL_FEEDBACK_PLUGIN_PROXY_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <feedback-plugin.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+typedef Dali::FeedbackPlugin::SoundStopCallBack SoundStopCallBack;
+typedef Dali::FeedbackPlugin::CreateFeedbackPlugin CreateFeedbackPlugin;
+
+/**
+ * Proxy class to dynamically load, use and unload feedback plugin.
+ */
+class FeedbackPluginProxy
+{
+public:
+
+ /**
+ * The default feedback plugin proxy.
+ */
+ static const char * const DEFAULT_OBJECT_NAME;
+
+public:
+
+ /**
+ * Constructor.
+ */
+ FeedbackPluginProxy( const std::string& sharedObjectName );
+
+ /**
+ * The destructor
+ */
+ ~FeedbackPluginProxy();
+
+ /**
+ * @copydoc Dali::Integration::FeedbackPlugin::PlayHaptic()
+ */
+ void PlayHaptic( const std::string& filePath );
+
+ /**
+ * @copydoc Dali::FeedbackPlugin::PlayHapticMonotone()
+ */
+ void PlayHapticMonotone( unsigned int duration );
+
+ /**
+ * @copydoc Dali::FeedbackPlugin::StopHaptic()
+ */
+ void StopHaptic();
+
+ /**
+ * @copydoc Dali::FeedbackPlugin::PlaySound()
+ */
+ int PlaySound( const std::string& fileName );
+
+ /**
+ * @copydoc Dali::FeedbackPlugin::StopSound()
+ */
+ void StopSound( int handle );
+
+ /**
+ * @copydoc Dali::FeedbackPlugin::PlayFeedbackPattern()
+ */
+ void PlayFeedbackPattern( int type, int pattern );
+
+private:
+
+ /**
+ * Dynamically loads the feedback plugin.
+ */
+ void Initialize();
+
+private:
+
+ bool mInitializeAttempted;
+ void* mLibHandle;
+ std::string mSharedObjectName;
+ CreateFeedbackPlugin* mCreatePluginFunctionPtr;
+ Dali::FeedbackPlugin* mFeedbackPlugin;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_FEEDBACK_PLUGIN_PROXY_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "file-descriptor-monitor.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Using Impl to hide away EFL specific members
+ */
+struct FileDescriptorMonitor::Impl
+{
+ // Construction
+ Impl(int fileDescriptor, boost::function<void()> functor)
+ : mFileDescriptor(fileDescriptor),
+ mFunctor(functor),
+ mHandler(NULL)
+ {
+ }
+
+ // Data
+ int mFileDescriptor;
+ boost::function<void()> mFunctor;
+ Ecore_Fd_Handler* mHandler;
+
+ // Static Methods
+
+ /**
+ * Called when the file descriptor receives an event.
+ */
+ static Eina_Bool EventDispatch(void* data, Ecore_Fd_Handler *handler)
+ {
+ Impl* impl = reinterpret_cast<Impl*>(data);
+
+ impl->mFunctor();
+
+ return ECORE_CALLBACK_RENEW;
+ }
+};
+
+FileDescriptorMonitor::FileDescriptorMonitor(int fileDescriptor, boost::function<void()> functor)
+{
+ mImpl = new Impl(fileDescriptor, functor);
+
+ if (fileDescriptor >= 0)
+ {
+ mImpl->mHandler = ecore_main_fd_handler_add(fileDescriptor, ECORE_FD_READ, &Impl::EventDispatch, mImpl, NULL, NULL);
+ }
+}
+
+FileDescriptorMonitor::~FileDescriptorMonitor()
+{
+ if (mImpl->mHandler)
+ {
+ ecore_main_fd_handler_del(mImpl->mHandler);
+ }
+
+ delete mImpl;
+ mImpl = NULL;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_FILE_DESCRIPTOR_MONITOR_H__
+#define __DALI_INTERNAL_FILE_DESCRIPTOR_MONITOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+
+namespace Dali
+{
+
+namespace Integration
+{
+class Core;
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Monitors the given file descriptor and whenever anything is written to it, it calls
+ * the given boost function.
+ */
+class FileDescriptorMonitor
+{
+public:
+
+ /**
+ * Constructor
+ * @param[in] fileDescriptor The file descriptor to monitor
+ * @param[in] functor The function to call when anything is written to the file descriptor
+ */
+ FileDescriptorMonitor(int fileDescriptor, boost::function<void()> functor);
+
+ /**
+ * Destructor
+ */
+ ~FileDescriptorMonitor();
+
+private:
+ struct Impl;
+ Impl* mImpl;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_FILE_DESCRIPTOR_MONITOR_H__
--- /dev/null
+# Common
+
+adaptor_common_src_files = \
+ $(adaptor_common_dir)/accessibility-manager.cpp \
+ $(adaptor_common_dir)/adaptor.cpp \
+ $(adaptor_common_dir)/color-controller.cpp \
+ $(adaptor_common_dir)/clipboard.cpp \
+ $(adaptor_common_dir)/clipboard-event-notifier.cpp \
+ $(adaptor_common_dir)/device-layout.cpp \
+ $(adaptor_common_dir)/drag-and-drop-detector.cpp \
+ $(adaptor_common_dir)/event-feeder.cpp \
+ $(adaptor_common_dir)/haptic-player.cpp \
+ $(adaptor_common_dir)/imf-manager.cpp \
+ $(adaptor_common_dir)/key.cpp \
+ $(adaptor_common_dir)/orientation.cpp \
+ $(adaptor_common_dir)/physical-keyboard.cpp \
+ $(adaptor_common_dir)/pixmap-image.cpp \
+ $(adaptor_common_dir)/render-surface.cpp \
+ $(adaptor_common_dir)/sound-player.cpp \
+ $(adaptor_common_dir)/style-monitor.cpp \
+ $(adaptor_common_dir)/tilt-sensor.cpp \
+ $(adaptor_common_dir)/timer.cpp \
+ $(adaptor_common_dir)/tts-player.cpp \
+ $(adaptor_common_dir)/virtual-keyboard.cpp \
+ $(adaptor_common_dir)/window.cpp
+
+adaptor_application_src_files = \
+ $(adaptor_common_dir)/application.cpp
+
+adaptor_application_internal_src_files = \
+ $(adaptor_common_dir)/application-impl.cpp \
+ $(adaptor_common_dir)/framework.cpp \
+ $(adaptor_common_dir)/command-line-options.cpp \
+ $(adaptor_common_dir)/abort-handler.cpp
+
+adaptor_common_internal_src_files = \
+ $(adaptor_common_dir)/accessibility-gesture-detector.cpp \
+ $(adaptor_common_dir)/accessibility-manager-impl.cpp \
+ $(adaptor_common_dir)/adaptor-impl.cpp \
+ $(adaptor_common_dir)/clipboard-event-notifier-impl.cpp \
+ $(adaptor_common_dir)/drag-and-drop-detector-impl.cpp \
+ $(adaptor_common_dir)/ecore-callback-manager.cpp \
+ $(adaptor_common_dir)/file-descriptor-monitor.cpp \
+ $(adaptor_common_dir)/haptic-player-impl.cpp \
+ $(adaptor_common_dir)/indicator-impl.cpp \
+ $(adaptor_common_dir)/indicator-buffer.cpp \
+ $(adaptor_common_dir)/kernel-trace.cpp \
+ $(adaptor_common_dir)/locale-utils.cpp \
+ $(adaptor_common_dir)/native-bitmap-buffer-impl.cpp \
+ $(adaptor_common_dir)/object-profiler.cpp \
+ $(adaptor_common_dir)/orientation-impl.cpp \
+ $(adaptor_common_dir)/physical-keyboard-impl.cpp \
+ $(adaptor_common_dir)/render-surface-impl.cpp \
+ $(adaptor_common_dir)/server-connection.cpp \
+ $(adaptor_common_dir)/shared-file.cpp \
+ $(adaptor_common_dir)/sound-player-impl.cpp \
+ $(adaptor_common_dir)/style-monitor-impl.cpp \
+ $(adaptor_common_dir)/tilt-sensor-impl.cpp \
+ $(adaptor_common_dir)/timer-impl.cpp \
+ $(adaptor_common_dir)/trigger-event.cpp \
+ $(adaptor_common_dir)/trigger-event-factory.cpp \
+ $(adaptor_common_dir)/tts-player-impl.cpp \
+ $(adaptor_common_dir)/virtual-keyboard-impl.cpp \
+ $(adaptor_common_dir)/vsync-monitor.cpp \
+ \
+ $(adaptor_common_dir)/events/gesture-manager.cpp \
+ $(adaptor_common_dir)/events/long-press-gesture-detector.cpp \
+ $(adaptor_common_dir)/events/pan-gesture-detector-base.cpp \
+ $(adaptor_common_dir)/events/pan-gesture-detector.cpp \
+ $(adaptor_common_dir)/events/pinch-gesture-detector.cpp \
+ $(adaptor_common_dir)/events/tap-gesture-detector.cpp \
+ \
+ $(adaptor_common_dir)/feedback/feedback-controller.cpp \
+ $(adaptor_common_dir)/feedback/feedback-plugin-proxy.cpp \
+ \
+ $(adaptor_common_dir)/gl/egl-factory.cpp \
+ $(adaptor_common_dir)/gl/egl-image-extensions.cpp \
+ $(adaptor_common_dir)/gl/egl-sync-implementation.cpp \
+ $(adaptor_common_dir)/gl/gl-proxy-implementation.cpp \
+ $(adaptor_common_dir)/gl/gl-extensions.cpp
+
+adaptor_common_internal_profile_src_files = \
+ $(adaptor_common_dir)/color-controller-impl.cpp \
+ $(adaptor_common_dir)/system-settings.cpp
+
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "framework.h"
+
+// EXTERNAL INCLUDES
+#include <app.h>
+#include <bundle.h>
+#include <Ecore.h>
+#include <boost/bind.hpp>
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <callback-manager.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+/// Application Status Enum
+enum
+{
+ APP_CREATE,
+ APP_TERMINATE,
+ APP_PAUSE,
+ APP_RESUME,
+ APP_RESET,
+ APP_LANGUAGE_CHANGE,
+};
+
+} // Unnamed namespace
+
+/**
+ * Impl to hide EFL data members
+ */
+struct Framework::Impl
+{
+ // Constructor
+
+ Impl(void* data)
+ {
+ mEventCallback.create = AppCreate;
+ mEventCallback.terminate = AppTerminate;
+ mEventCallback.pause = AppPause;
+ mEventCallback.resume = AppResume;
+ mEventCallback.service = AppService;
+ mEventCallback.low_memory = NULL;
+ mEventCallback.low_battery = NULL;
+ mEventCallback.device_orientation = DeviceRotated;
+ mEventCallback.language_changed = AppLanguageChange;
+ mEventCallback.region_format_changed = NULL;
+
+ mCallbackManager = CallbackManager::New();
+ }
+
+ ~Impl()
+ {
+ // we're quiting the main loop so
+ // mCallbackManager->RemoveAllCallBacks() does not need to be called
+ // to delete our abort handler
+ delete mCallbackManager;
+ }
+
+ // Data
+
+ boost::function<void(void)> mAbortCallBack;
+ app_event_callback_s mEventCallback;
+ CallbackManager *mCallbackManager;
+ // Static methods
+
+ /**
+ * Called by AppCore on application creation.
+ */
+ static bool AppCreate(void *data)
+ {
+ return static_cast<Framework*>(data)->SlpAppStatusHandler(APP_CREATE);
+ }
+
+ /**
+ * Called by AppCore when the application should terminate.
+ */
+ static void AppTerminate(void *data)
+ {
+ static_cast<Framework*>(data)->SlpAppStatusHandler(APP_TERMINATE);
+ }
+
+ /**
+ * Called by AppCore when the application is paused.
+ */
+ static void AppPause(void *data)
+ {
+ static_cast<Framework*>(data)->SlpAppStatusHandler(APP_PAUSE);
+ }
+
+ /**
+ * Called by AppCore when the application is resumed.
+ */
+ static void AppResume(void *data)
+ {
+ static_cast<Framework*>(data)->SlpAppStatusHandler(APP_RESUME);
+ }
+
+ /**
+ * Called by AppCore when the application is launched from another module (e.g. homescreen).
+ * @param[in] b the bundle data which the launcher module sent
+ */
+ static void AppService(service_h service, void *data)
+ {
+ Framework* framework = static_cast<Framework*>(data);
+
+ if(framework)
+ {
+ bundle *bundleData = NULL;
+ service_to_bundle(service, &bundleData);
+
+ if(bundleData)
+ {
+ // get bundle name
+ char* bundleName = const_cast<char*>(bundle_get_val(bundleData, "name"));
+ if(bundleName != NULL)
+ {
+ framework->SetBundleName(bundleName);
+ }
+
+ // get bundle id
+ char* bundleId = const_cast<char*>(bundle_get_val(bundleData, "id"));
+ if(bundleId != NULL)
+ {
+ framework->SetBundleId(bundleId);
+ }
+ }
+ framework->SlpAppStatusHandler(APP_RESET);
+ }
+ }
+
+ /**
+ * Called by AppCore when the language changes on the device.
+ */
+ static void AppLanguageChange(void* data)
+ {
+ static_cast<Framework*>(data)->SlpAppStatusHandler(APP_LANGUAGE_CHANGE);
+ }
+
+ static void DeviceRotated(app_device_orientation_e orientation, void *user_data)
+ {
+ switch(orientation)
+ {
+ case APP_DEVICE_ORIENTATION_0:
+ break;
+ case APP_DEVICE_ORIENTATION_90:
+ break;
+ case APP_DEVICE_ORIENTATION_180:
+ break;
+ case APP_DEVICE_ORIENTATION_270:
+ break;
+ }
+ }
+
+};
+
+Framework::Framework(Framework::Observer& observer, int *argc, char ***argv, const std::string& name)
+: mObserver(observer),
+ mInitialised(false),
+ mRunning(false),
+ mArgc(argc),
+ mArgv(argv),
+ mName(name),
+ mBundleName(""),
+ mBundleId(""),
+ mAbortHandler(boost::bind(&Framework::AbortCallback, this)),
+ mImpl(NULL)
+{
+ InitThreads();
+ mImpl = new Impl(this);
+}
+
+Framework::~Framework()
+{
+ if (mRunning)
+ {
+ Quit();
+ }
+
+ delete mImpl;
+}
+
+void Framework::Run()
+{
+ mRunning = true;
+
+ app_efl_main(mArgc, mArgv, &mImpl->mEventCallback, this);
+
+ mRunning = false;
+}
+
+void Framework::Quit()
+{
+ app_efl_exit();
+}
+
+bool Framework::IsMainLoopRunning()
+{
+ return mRunning;
+}
+
+void Framework::AddAbortCallback(boost::function<void(void)> callBack)
+{
+ mImpl->mAbortCallBack = callBack;
+}
+
+std::string Framework::GetBundleName() const
+{
+ return mBundleName;
+}
+
+void Framework::SetBundleName(const std::string& name)
+{
+ mBundleName = name;
+}
+
+std::string Framework::GetBundleId() const
+{
+ return mBundleId;
+}
+
+void Framework::SetBundleId(const std::string& id)
+{
+ mBundleId = id;
+}
+
+void Framework::AbortCallback( )
+{
+ // if an abort call back has been installed run it.
+ if (mImpl->mAbortCallBack)
+ {
+ mImpl->mAbortCallBack();
+ }
+ else
+ {
+ Quit();
+ }
+}
+
+bool Framework::SlpAppStatusHandler(int type)
+{
+ switch (type)
+ {
+ case APP_CREATE:
+ {
+ mInitialised = true;
+
+ // Connect to abnormal exit signals
+ mAbortHandler.AbortOnSignal( SIGINT );
+ mAbortHandler.AbortOnSignal( SIGQUIT );
+ mAbortHandler.AbortOnSignal( SIGKILL );
+
+ mObserver.OnInit();
+ break;
+ }
+
+ case APP_RESET:
+ mObserver.OnReset();
+ break;
+
+ case APP_RESUME:
+ mObserver.OnResume();
+ break;
+
+ case APP_TERMINATE:
+ mObserver.OnTerminate();
+ break;
+
+ case APP_PAUSE:
+ mObserver.OnPause();
+ break;
+
+ case APP_LANGUAGE_CHANGE:
+ mObserver.OnLanguageChanged();
+ break;
+
+ default:
+ break;
+ }
+
+ return true;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_FRAMEWORK_H__
+#define __DALI_INTERNAL_FRAMEWORK_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <boost/function.hpp>
+
+// INTERNAL INCLUDES
+#include "abort-handler.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * The Framework class is used to register callbacks with the SLP platform so that
+ * we know when any of the application lifecycle events occur. This includes events
+ * like when our application is to be initialised, terminated, paused, resumed etc.
+ */
+class Framework
+{
+public:
+
+ /**
+ * Observer class for the framework.
+ */
+ class Observer
+ {
+ public:
+
+ /**
+ * Invoked when the application is to be initialised.
+ */
+ virtual void OnInit() {}
+
+ /**
+ * Invoked when the application is to be terminated.
+ */
+ virtual void OnTerminate() {}
+
+ /**
+ * Invoked when the application is to be paused.
+ */
+ virtual void OnPause() {}
+
+ /**
+ * Invoked when the application is to be resumed.
+ */
+ virtual void OnResume() {}
+
+ /**
+ * Invoked when the application is to be reset.
+ */
+ virtual void OnReset() {}
+
+ /**
+ * Invoked when the language of the device is changed.
+ */
+ virtual void OnLanguageChanged() {}
+ };
+
+public:
+
+ /**
+ * Constructor
+ * @param[in] observer The observer of the Framework.
+ * @param[in] argc A pointer to the number of arguments.
+ * @param[in] argv A pointer the the argument list.
+ */
+ Framework(Observer& observer, int* argc, char ***argv, const std::string& name);
+
+ /**
+ * Destructor
+ */
+ ~Framework();
+
+public:
+
+ /**
+ * Runs the main loop of framework
+ */
+ void Run();
+
+ /**
+ * Quits the main loop
+ */
+ void Quit();
+
+ /**
+ * Checks whether the main loop of the framework is running.
+ * @return true, if the main loop is running, false otherwise.
+ */
+ bool IsMainLoopRunning();
+
+ /**
+ * If the main loop aborts unexpectedly, then the connected callback function is called.
+ * @param[in] callBack The function to call.
+ * @note Only one callback can be registered. The last callback to be set will be called on abort.
+ */
+ void AddAbortCallback(boost::function<void(void)> callBack);
+
+ /**
+ * Gets bundle name which was passed in app_reset callback.
+ */
+ std::string GetBundleName() const;
+
+ /**
+ * Gets bundle id which was passed in app_reset callback.
+ */
+ std::string GetBundleId() const;
+
+private:
+
+ // Undefined
+ Framework(const Framework&);
+ Framework& operator=(Framework&);
+
+private:
+ /**
+ * Called by the SLP framework when an application lifecycle event occurs.
+ * @param[in] type The type of event occurred.
+ */
+ bool SlpAppStatusHandler(int type);
+
+ /**
+ * Called app_reset callback was called with bundle.
+ */
+ void SetBundleName(const std::string& name);
+
+ /**
+ * Called app_reset callback was called with bundle.
+ */
+ void SetBundleId(const std::string& id);
+
+ /**
+ * Called if the application is aborted.
+ */
+ void AbortCallback();
+
+ /**
+ * Called for initializing on specified backend. (X11 or Wayland)
+ */
+ void InitThreads();
+
+private:
+ Observer& mObserver;
+ bool mInitialised;
+ bool mRunning;
+ int* mArgc;
+ char*** mArgv;
+ std::string mName;
+ std::string mBundleName;
+ std::string mBundleId;
+ AbortHandler mAbortHandler;
+
+private: // impl members
+
+ struct Impl;
+ Impl* mImpl;
+
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_FRAMEWORK_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "egl-factory.h"
+
+// INTERNAL INCLUDES
+#include <gl/egl-implementation.h>
+#include <gl/egl-image-extensions.h>
+#include <gl/egl-sync-implementation.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+EglFactory::EglFactory()
+: mEglImplementation(NULL),
+ mEglImageExtensions(NULL),
+ mEglSync(new EglSyncImplementation) // Created early, as needed by Core constructor
+{
+}
+
+EglFactory::~EglFactory()
+{
+ // Ensure the EGL implementation is destroyed
+ delete mEglImageExtensions;
+ delete mEglImplementation;
+ delete mEglSync;
+}
+
+EglInterface* EglFactory::Create()
+{
+ // Created by RenderThread (After Core construction)
+ mEglImplementation = new EglImplementation();
+ mEglImageExtensions = new EglImageExtensions(mEglImplementation);
+
+ mEglSync->Initialize(mEglImplementation); // The sync impl needs the EglDisplay
+ return mEglImplementation;
+}
+
+void EglFactory::Destroy()
+{
+ delete mEglImageExtensions;
+ mEglImageExtensions = NULL;
+ delete mEglImplementation;
+ mEglImplementation = NULL;
+}
+
+EglInterface* EglFactory::GetImplementation()
+{
+ return mEglImplementation;
+}
+
+EglImageExtensions* EglFactory::GetImageExtensions()
+{
+ return mEglImageExtensions;
+}
+
+EglSyncImplementation* EglFactory::GetSyncImplementation()
+{
+ return mEglSync;
+}
+
+} // Adaptor
+} // Internal
+} // Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H__
+#define __DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+#include <base/interfaces/egl-factory-interface.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class EglImplementation;
+class EglImageExtensions;
+class EglSyncImplementation;
+
+class EglFactory : public EglFactoryInterface
+{
+public:
+ /**
+ * Constructor
+ */
+ EglFactory();
+
+ /**
+ * Destructor
+ */
+ virtual ~EglFactory();
+
+ /**
+ * Create an EGL Implementation
+ * @return[in] An implementation
+ */
+ EglInterface* Create();
+
+ /**
+ * Destroy the EGL Implementation
+ */
+ void Destroy();
+
+ /**
+ * Get an implementation if one has been created.
+ * @return An implementation, or NULL if one has not yet been created.
+ */
+ EglInterface* GetImplementation();
+
+ /**
+ * Get the image extension
+ */
+ EglImageExtensions* GetImageExtensions();
+
+ /**
+ * Get the fence sync implementation
+ * @return An implementation of fence sync
+ */
+ EglSyncImplementation* GetSyncImplementation();
+
+private:
+ /** Undefined */
+ EglFactory(const EglFactory& rhs);
+ EglFactory& operator=(const EglFactory& rhs);
+
+private:
+ EglImplementation* mEglImplementation;
+ EglImageExtensions* mEglImageExtensions;
+ EglSyncImplementation* mEglSync;
+};
+
+}
+}
+}
+
+#endif //__DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+// CLASS HEADER
+#include "egl-image-extensions.h"
+
+// EXTERNAL INCLUDES
+#if DALI_GLES_VERSION >= 30
+#include <GLES3/gl3.h>
+#include <GLES3/gl3ext.h>
+
+#else
+#include <GLES2/gl2.h>
+#endif // DALI_GLES_VERSION >= 30
+
+#include <GLES2/gl2ext.h>
+
+#include <EGL/eglext.h>
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <gl/egl-implementation.h>
+
+
+namespace
+{
+// function pointers assigned in InitializeEglImageKHR
+PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = 0;
+PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = 0;
+PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES = 0;
+} // unnamed namespace
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+EglImageExtensions::EglImageExtensions(EglImplementation* eglImpl)
+: mEglImplementation(eglImpl),
+ mImageKHRInitialized(false),
+ mImageKHRInitializeFailed(false)
+{
+ DALI_ASSERT_ALWAYS( eglImpl && "EGL Implementation not instantiated" );
+}
+
+EglImageExtensions::~EglImageExtensions()
+{
+}
+
+void* EglImageExtensions::CreateImageKHR(EGLClientBuffer pixmap)
+{
+ if (mImageKHRInitialized == false)
+ {
+ InitializeEglImageKHR();
+ }
+
+ if (mImageKHRInitialized == false)
+ {
+ return NULL;
+ }
+
+ // Use the EGL image extension
+ const EGLint attribs[] =
+ {
+ EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
+ EGL_NONE
+ };
+
+ EGLImageKHR eglImage = eglCreateImageKHR( mEglImplementation->GetDisplay(),
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ pixmap,
+ attribs );
+
+ DALI_ASSERT_DEBUG( EGL_NO_IMAGE_KHR != eglImage && "X11Image::GlExtensionCreate eglCreateImageKHR failed!\n");
+ if( EGL_NO_IMAGE_KHR != eglImage )
+ {
+ switch( eglGetError() )
+ {
+ case EGL_SUCCESS :
+ {
+ break;
+ }
+ case EGL_BAD_DISPLAY:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object" );
+ break;
+ }
+ case EGL_BAD_CONTEXT:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_CONTEXT: Invalid EGLContext object" );
+ break;
+ }
+ case EGL_BAD_PARAMETER:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_PARAMETER: Invalid target parameter or attribute in attrib_list" );
+ break;
+ }
+ case EGL_BAD_MATCH:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_MATCH: attrib_list does not match target" );
+ break;
+ }
+ case EGL_BAD_ACCESS:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_ACCESS: Previously bound off-screen, or EGLImage sibling error" );
+ break;
+ }
+ case EGL_BAD_ALLOC:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_ALLOC: Insufficient memory is available" );
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+
+ return (void*)eglImage;
+}
+
+void EglImageExtensions::DestroyImageKHR(void* eglImageKHR)
+{
+ DALI_ASSERT_DEBUG( mImageKHRInitialized );
+
+ if( ! mImageKHRInitialized )
+ {
+ return;
+ }
+
+ if( eglImageKHR == NULL )
+ {
+ return;
+ }
+
+ EGLImageKHR eglImage = static_cast<EGLImageKHR>(eglImageKHR);
+
+ EGLBoolean result = eglDestroyImageKHR(mEglImplementation->GetDisplay(), eglImage);
+
+ if( EGL_FALSE == result )
+ {
+ switch( eglGetError() )
+ {
+ case EGL_BAD_DISPLAY:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object" );
+ break;
+ }
+ case EGL_BAD_PARAMETER:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_PARAMETER: eglImage is not a valid EGLImageKHR object created with respect to EGLDisplay" );
+ break;
+ }
+ case EGL_BAD_ACCESS:
+ {
+ DALI_LOG_ERROR( "EGL_BAD_ACCESS: EGLImage sibling error" );
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+}
+
+void EglImageExtensions::TargetTextureKHR(void* eglImageKHR)
+{
+ DALI_ASSERT_DEBUG( mImageKHRInitialized );
+
+ if( eglImageKHR != NULL )
+ {
+ EGLImageKHR eglImage = static_cast<EGLImageKHR>(eglImageKHR);
+
+#ifdef EGL_ERROR_CHECKING
+ GLint glError = glGetError();
+#endif
+
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)eglImage);
+
+#ifdef EGL_ERROR_CHECKING
+ glError = glGetError();
+ if( GL_NO_ERROR != glError )
+ {
+ DALI_LOG_ERROR(" glEGLImageTargetTexture2DOES returned error %0x04x\n", glError );
+ }
+#endif
+ }
+}
+
+void EglImageExtensions::InitializeEglImageKHR()
+{
+ // avoid trying to reload extended KHR functions, if it fails the first time
+ if( ! mImageKHRInitializeFailed )
+ {
+ eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress("eglCreateImageKHR"); /* parasoft-suppress MISRA2004-11_1_DMC "Using EGL defined functions." */
+ eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) eglGetProcAddress("eglDestroyImageKHR"); /* parasoft-suppress MISRA2004-11_1_DMC "Using EGL defined functions." */
+ glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) eglGetProcAddress("glEGLImageTargetTexture2DOES"); /* parasoft-suppress MISRA2004-11_1_DMC "Using EGL defined functions." */
+ }
+
+ if (eglCreateImageKHR && eglDestroyImageKHR && glEGLImageTargetTexture2DOES)
+ {
+ mImageKHRInitialized = true;
+ }
+ else
+ {
+ mImageKHRInitializeFailed = true;
+ }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_EGL_IMAGE_EXTENSIONS_H__
+#define __DALI_INTERNAL_EGL_IMAGE_EXTENSIONS_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <EGL/egl.h>
+
+#include <dali/public-api/images/pixel.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class EglImplementation;
+
+/**
+ * EglImageExtensions class provides EGL image extension support
+ */
+class EglImageExtensions
+{
+public:
+ /**
+ * Constructor
+ */
+ EglImageExtensions(EglImplementation* impl);
+
+ /**
+ * Destructor
+ */
+ ~EglImageExtensions();
+
+
+public: // EGLImageKHR extension support
+
+ /**
+ * If the EGL Image extension is available this function returns a
+ * EGLImageKHR
+ * @param pixmap The pixmap
+ * @return an object that holds a EGLImageKHR
+ */
+ void* CreateImageKHR(EGLClientBuffer pixmap);
+
+ /**
+ * If the EGL Image extension is available this function
+ * destroys the a EGLImageKHR
+ * @param eglImageKHR Object that holds a EGLImageKHR
+ */
+ void DestroyImageKHR(void* eglImageKHR);
+
+ /**
+ * defines a 2D texture
+ * @param eglImageKHR Object that holds a EGLImageKHR
+ */
+ void TargetTextureKHR(void* eglImageKHR);
+
+ /**
+ * Get the functions for using ImageKHR
+ */
+ void InitializeEglImageKHR();
+
+private:
+ EglImplementation* mEglImplementation;
+
+ bool mImageKHRInitialized; ///< Flag for whether extended KHR functions loaded
+ bool mImageKHRInitializeFailed; ///< Flag to avoid trying to reload extended KHR functions, if
+ /// it fails the first time
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_EGL_IMAGE_EXTENSIONS_H__
--- /dev/null
+#ifndef __DALI_INTERNAL_EGL_IMPLEMENTATION_H__
+#define __DALI_INTERNAL_EGL_IMPLEMENTATION_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <boost/any.hpp>
+#include <dali/public-api/common/dali-vector.h>
+
+// INTERNAL INCLUDES
+#include <base/interfaces/egl-interface.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+enum ColorDepth
+{
+ COLOR_DEPTH_24 = 24,
+ COLOR_DEPTH_32 = 32
+};
+
+/**
+ * EglImplementation class provides an EGL implementation.
+ */
+class EglImplementation : public EglInterface
+{
+public:
+ /**
+ * Constructor
+ */
+ EglImplementation();
+
+ /**
+ * Destructor
+ */
+ virtual ~EglImplementation();
+
+public:
+
+ /**
+ * (Called from ECoreX::RenderSurface, not RenderThread, so not in i/f, hence, not virtual)
+ * Initialize GL
+ * @param display The display
+ * @param isOwnSurface whether the surface is own or not
+ * @return true on success, false on failure
+ */
+ bool InitializeGles( EGLNativeDisplayType display, bool isOwnSurface = true );
+
+ /**
+ * Create the OpenGL context.
+ * @return true if successful
+ */
+ virtual bool CreateContext();
+
+ /**
+ * Destroy the OpenGL context.
+ */
+ void DestroyContext();
+
+ /**
+ * Destroy the OpenGL surface.
+ */
+ void DestroySurface();
+
+ /**
+ * Make the OpenGL context current
+ */
+ virtual void MakeContextCurrent();
+
+ /**
+ * clear the OpenGL context
+ */
+ void MakeContextNull();
+
+ /**
+ * Terminate GL
+ */
+ virtual void TerminateGles();
+
+ /**
+ * Checks if GL is initialised
+ * @return true if it is
+ */
+ bool IsGlesInitialized() const;
+
+ /**
+ * Sets the refresh sync mode.
+ * @see SyncMode
+ */
+ virtual bool SetRefreshSync( SyncMode mode );
+
+ /**
+ * Performs an OpenGL swap buffers command
+ */
+ virtual void SwapBuffers();
+
+ /**
+ * Performs an OpenGL copy buffers command
+ */
+ virtual void CopyBuffers();
+
+ /**
+ * Performs an EGL wait GL command
+ */
+ virtual void WaitGL();
+
+ /**
+ * Choose config of egl
+ * @param isWindowType whether the config for window or pixmap
+ * @param colorDepth Bit per pixel value (ex. 32 or 24)
+ */
+ void ChooseConfig( bool isWindowType, ColorDepth depth );
+
+ /**
+ * Create an OpenGL surface using a window
+ * @param window The window to create the surface on
+ * @param colorDepth Bit per pixel value (ex. 32 or 24)
+ * @return true on success, false on failure
+ */
+ void CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth );
+
+ /**
+ * Create the OpenGL surface using a pixmap
+ * @param pixmap The pixmap to create the surface on
+ * @param colorDepth Bit per pixel value (ex. 32 or 24)
+ * @return true on success, false on failure
+ */
+ void CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth );
+
+ /**
+ * Replaces the render surface
+ * @param[in] window, the window to create the new surface on
+ * @param[in] display, the display
+ * @return true if the context was lost due to a change in display
+ * between old surface and new surface
+ */
+ bool ReplaceSurfaceWindow( EGLNativeWindowType window, EGLNativeDisplayType display );
+
+ /**
+ * Replaces the render surface
+ * @param[in] pixmap, the pixmap to create the new surface on
+ * @param[in] display, the display
+ * @return true if the context was lost due to a change in x-display
+ * between old surface and new surface
+ */
+ bool ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLNativeDisplayType display );
+
+ /**
+ * returns the display with which this object was initialized
+ * @return the EGL Display.
+ */
+ EGLDisplay GetDisplay() const;
+
+ /**
+ * Returns the EGL context
+ * @return the EGL context.
+ */
+ EGLContext GetContext() const;
+
+private:
+
+ Vector<EGLint> mContextAttribs;
+
+ EGLNativeDisplayType mEglNativeDisplay;
+ EGLNativeWindowType mEglNativeWindow;
+ EGLNativePixmapType mEglNativePixmap;
+
+ EGLDisplay mEglDisplay;
+ EGLConfig mEglConfig;
+ EGLContext mEglContext;
+ EGLSurface mEglSurface;
+
+ bool mGlesInitialized;
+ bool mIsOwnSurface;
+ SyncMode mSyncMode;
+ bool mContextCurrent;
+ bool mIsWindow;
+ ColorDepth mColorDepth;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_EGL_IMPLEMENTATION_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <gl/egl-sync-implementation.h>
+
+// EXTERNAL INCLUDES
+
+#ifdef _ARCH_ARM_
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <EGL/eglext.h>
+
+#endif
+
+#include <boost/thread/mutex.hpp>
+
+// INTERNAL INCLUDES
+#include <gl/egl-implementation.h>
+#include <dali/integration-api/debug.h>
+
+#ifdef _ARCH_ARM_
+
+// function pointers
+static PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR = NULL;
+static PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR = NULL;
+static PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR = NULL;
+
+#endif
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+#ifdef _ARCH_ARM_
+
+EglSyncObject::EglSyncObject( EglImplementation& eglSyncImpl )
+: mEglSync(NULL),
+ mEglImplementation(eglSyncImpl)
+{
+ EGLDisplay display = mEglImplementation.GetDisplay();
+ mEglSync = eglCreateSyncKHR( display, EGL_SYNC_FENCE_KHR, NULL );
+ if (mEglSync == EGL_NO_SYNC_KHR)
+ {
+ DALI_LOG_ERROR("eglCreateSyncKHR failed %#0.4x\n", eglGetError());
+ mEglSync = NULL;
+ }
+}
+
+EglSyncObject::~EglSyncObject()
+{
+ if( mEglSync != NULL )
+ {
+ eglDestroySyncKHR( mEglImplementation.GetDisplay(), mEglSync );
+ EGLint error = eglGetError();
+ if( EGL_SUCCESS != error )
+ {
+ DALI_LOG_ERROR("eglDestroySyncKHR failed %#0.4x\n", error);
+ }
+ }
+}
+
+bool EglSyncObject::IsSynced()
+{
+ bool synced = false;
+
+ if( mEglSync != NULL )
+ {
+ EGLint result = eglClientWaitSyncKHR( mEglImplementation.GetDisplay(), mEglSync, 0, 0ull );
+ EGLint error = eglGetError();
+ if( EGL_SUCCESS != error )
+ {
+ DALI_LOG_ERROR("eglClientWaitSyncKHR failed %#0.4x\n", error);
+ }
+ else if( result == EGL_CONDITION_SATISFIED_KHR )
+ {
+ synced = true;
+ }
+ }
+
+ return synced;
+}
+
+EglSyncImplementation::EglSyncImplementation()
+: mEglImplementation( NULL ),
+ mSyncInitialized( false ),
+ mSyncInitializeFailed( false )
+{
+}
+
+EglSyncImplementation::~EglSyncImplementation()
+{
+}
+
+void EglSyncImplementation::Initialize( EglImplementation* eglImpl )
+{
+ mEglImplementation = eglImpl;
+}
+
+Integration::GlSyncAbstraction::SyncObject* EglSyncImplementation::CreateSyncObject()
+{
+ DALI_ASSERT_ALWAYS( mEglImplementation && "Sync Implementation not initialized" );
+ if( mSyncInitialized == false )
+ {
+ InitializeEglSync();
+ }
+
+ EglSyncObject* syncObject = new EglSyncObject(*mEglImplementation);
+ mSyncObjects.PushBack( syncObject );
+ return syncObject;
+}
+
+void EglSyncImplementation::DestroySyncObject( Integration::GlSyncAbstraction::SyncObject* syncObject )
+{
+ DALI_ASSERT_ALWAYS( mEglImplementation && "Sync Implementation not initialized" );
+
+ if( mSyncInitialized == false )
+ {
+ InitializeEglSync();
+ }
+
+ for( SyncIter iter=mSyncObjects.Begin(), end=mSyncObjects.End(); iter != end; ++iter )
+ {
+ if( *iter == syncObject )
+ {
+ mSyncObjects.Erase(iter);
+ break;
+ }
+ }
+ EglSyncObject* eglSyncObject = static_cast<EglSyncObject*>(syncObject);
+ delete eglSyncObject;
+}
+
+void EglSyncImplementation::InitializeEglSync()
+{
+ if( ! mSyncInitializeFailed )
+ {
+ eglCreateSyncKHR = (PFNEGLCREATESYNCKHRPROC)eglGetProcAddress("eglCreateSyncKHR");
+ eglClientWaitSyncKHR = (PFNEGLCLIENTWAITSYNCKHRPROC)eglGetProcAddress("eglClientWaitSyncKHR");
+ eglDestroySyncKHR = (PFNEGLDESTROYSYNCKHRPROC)eglGetProcAddress("eglDestroySyncKHR");
+ }
+
+ if( eglCreateSyncKHR && eglClientWaitSyncKHR && eglDestroySyncKHR )
+ {
+ mSyncInitialized = true;
+ }
+ else
+ {
+ mSyncInitializeFailed = true;
+ }
+}
+
+#else
+
+EglSyncObject::EglSyncObject( EglImplementation& eglImpl )
+: mPollCounter(3),
+ mEglImplementation(eglImpl)
+{
+}
+
+EglSyncObject::~EglSyncObject()
+{
+}
+
+bool EglSyncObject::IsSynced()
+{
+ if(mPollCounter <= 0)
+ {
+ return true;
+ }
+ --mPollCounter;
+ return false;
+}
+
+EglSyncImplementation::EglSyncImplementation()
+: mEglImplementation( NULL )
+{
+}
+
+EglSyncImplementation::~EglSyncImplementation()
+{
+}
+
+void EglSyncImplementation::Initialize( EglImplementation* eglImpl )
+{
+ mEglImplementation = eglImpl;
+}
+
+Integration::GlSyncAbstraction::SyncObject* EglSyncImplementation::CreateSyncObject()
+{
+ DALI_ASSERT_ALWAYS( mEglImplementation && "Sync Implementation not initialized" );
+ return new EglSyncObject(*mEglImplementation);
+}
+
+void EglSyncImplementation::DestroySyncObject(Integration::GlSyncAbstraction::SyncObject* syncObject)
+{
+ DALI_ASSERT_ALWAYS( mEglImplementation && "Sync Implementation not initialized" );
+
+ // The abstraction's virtual destructor is protected, so that Core can't delete the sync objects
+ // directly (This object also needs removing from the mSyncObject container in the ARM
+ // implementation above). We therefore need to cast to the actual implementation object first.
+ EglSyncObject* eglSyncObject = static_cast<EglSyncObject*>(syncObject);
+ delete eglSyncObject;
+}
+
+void EglSyncImplementation::InitializeEglSync()
+{
+}
+
+#endif
+
+} // namespace Dali
+} // namespace Internal
+} // namespace Adaptor
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_EGL_SYNC_IMPLEMENTATION_H__
+#define __DALI_INTERNAL_ADAPTOR_EGL_SYNC_IMPLEMENTATION_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/dali-vector.h>
+#include <dali/integration-api/gl-sync-abstraction.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class EglImplementation;
+
+class EglSyncObject : public Integration::GlSyncAbstraction::SyncObject
+{
+public:
+ /**
+ * Constructor
+ */
+ EglSyncObject( EglImplementation& eglSyncImpl );
+
+ /**
+ * Destructor
+ */
+ virtual ~EglSyncObject();
+
+ /**
+ * @copydoc Dali::Integration::GlSyncAbstraction::SyncObject::IsSynced()
+ */
+ virtual bool IsSynced();
+
+private:
+#ifdef _ARCH_ARM_
+ EGLSyncKHR mEglSync;
+#else
+ int mPollCounter; // Implementations without fence sync use a 3 frame counter
+#endif
+ EglImplementation& mEglImplementation;
+};
+
+
+/**
+ * GlSyncImplementation is a concrete implementation for GlSyncAbstraction.
+ * It provides fence syncing for resources such as FrameBuffers using EGL extensions
+ *
+ * Sync objects are created in the render thread after a render instruction
+ * has been processed (i.e. GL draw calls have completed for a given FB), and
+ * tested in the update
+ */
+class EglSyncImplementation : public Integration::GlSyncAbstraction
+{
+public:
+ /**
+ * Constructor
+ */
+ EglSyncImplementation();
+
+ /**
+ * Destructor
+ */
+ virtual ~EglSyncImplementation();
+
+ /**
+ * Initialize the sync object with the Egl implementation.
+ * @param[in] impl The EGL implementation (to access display)
+ */
+ void Initialize( EglImplementation* impl );
+
+ /**
+ * @copydoc Dali::Integration::GlSyncAbstraction::CreateSyncObject()
+ */
+ virtual SyncObject* CreateSyncObject();
+
+ /**
+ * @copydoc Dali::Integration::GlSyncAbstraction::DestroySyncObject()
+ */
+ virtual void DestroySyncObject(SyncObject* syncObject);
+
+private:
+ /**
+ * Set up the function pointers
+ */
+ void InitializeEglSync();
+
+private:
+ typedef Vector<EglSyncObject*> SyncContainer;
+ typedef SyncContainer::Iterator SyncIter;
+
+ EglImplementation* mEglImplementation; ///< Egl implementation (to get display)
+ bool mSyncInitialized; ///< Flag to perform initialization on first use
+ bool mSyncInitializeFailed; ///< Flag to avoid reloading functions if failed once
+
+ SyncContainer mSyncObjects;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_EGL_ADAPTOR_SYNC_IMPLEMENTATION_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "gl-extensions.h"
+
+// EXTERNAL INCLUDES
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECoreX
+{
+
+GlExtensions::GlExtensions()
+ : mInitialized( false )
+{
+}
+
+GlExtensions::~GlExtensions()
+{
+}
+
+#if DALI_GLES_VERSION < 30
+
+void GlExtensions::DiscardFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
+{
+ // initialize extension on first use as on some hw platforms a context
+ // has to be bound for the extensions to return correct pointer
+ if( !mInitialized )
+ {
+ Initialize();
+ }
+
+#ifdef PFNGLDISCARDFRAMEBUFFEREXTPROC
+ if( mGlDiscardFramebuffer )
+ {
+ mGlDiscardFramebuffer(target, numAttachments, attachments);
+ }
+ else
+ {
+ DALI_LOG_ERROR("Error: glDiscardFramebufferEXT extension is not available\n");
+ }
+#endif
+}
+
+void GlExtensions::GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
+{
+ // initialize extension on first use as on some hw platforms a context
+ // has to be bound for the extensions to return correct pointer
+ if( !mInitialized )
+ {
+ Initialize();
+ }
+
+#ifdef PFNGLGETPROGRAMBINARYOESPROC
+ if (mGlGetProgramBinaryOES)
+ {
+ mGlGetProgramBinaryOES(program, bufSize, length, binaryFormat, binary);
+ }
+ else
+ {
+ DALI_LOG_ERROR("Error: glGetProgramBinaryOES extension is not available\n");
+ DALI_ASSERT_DEBUG(0);
+ }
+#endif
+}
+
+void GlExtensions::ProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length)
+{
+ // initialize extension on first use as on some hw platforms a context
+ // has to be bound for the extensions to return correct pointer
+ if( !mInitialized )
+ {
+ Initialize();
+ }
+
+#ifdef PFNGLGETPROGRAMBINARYOESPROC
+ if (mGlProgramBinaryOES)
+ {
+ mGlProgramBinaryOES(program, binaryFormat, binary, length);
+ }
+ else
+ {
+ DALI_LOG_ERROR("Error: glProgramBinaryOES extension is not available\n");
+ DALI_ASSERT_DEBUG(0);
+ }
+#endif
+}
+
+void GlExtensions::Initialize()
+{
+ mInitialized = true;
+
+#ifdef PFNGLDISCARDFRAMEBUFFEREXTPROC
+ mGlDiscardFramebuffer = (PFNGLDISCARDFRAMEBUFFEREXTPROC) eglGetProcAddress("glDiscardFramebufferEXT");
+#endif
+
+#ifdef PFNGLGETPROGRAMBINARYOESPROC
+ mGlGetProgramBinaryOES = (PFNGLGETPROGRAMBINARYOESPROC) eglGetProcAddress("glGetProgramBinaryOES");
+ mGlProgramBinaryOES = (PFNGLPROGRAMBINARYOESPROC) eglGetProcAddress("glProgramBinaryOES");
+#endif
+
+}
+
+#endif // DALI_GLES_VERSION < 30
+
+} // namespace ECoreX
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_GL_EXTENSION_H__
+#define __DALI_INTERNAL_GL_EXTENSION_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+#if DALI_GLES_VERSION >= 30
+#include <GLES3/gl3.h>
+#include <GLES3/gl3ext.h>
+#else
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#endif
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECoreX
+{
+
+/**
+ * GlExtensions class provides GL extensions support
+ */
+class GlExtensions
+{
+public:
+
+ /**
+ * Constructor
+ */
+ GlExtensions();
+
+ /**
+ * Destructor
+ */
+ ~GlExtensions();
+
+
+public:
+
+#if DALI_GLES_VERSION < 30
+
+ /**
+ * If the GL extension is available this function discards specified data in attachments
+ * from being copied from the target to improve performance.
+ *
+ * Usage: GLenum attachments[] = { GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT };
+ * DiscardFrameBufferEXT(GL_FRAMEBUFFER, 2, attachments);
+ *
+ * @param target is usually GL_FRAMEBUFFER
+ * @param numAttachments is the count of attachments
+ * @param attachments is a pointer to the attachments
+ */
+ void DiscardFrameBuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments);
+
+ /**
+ * GLES extension
+ * Returns the program object's executable bytecode.
+ * @param[in] program The program object's name/id
+ * @param[in] bufSize The maximum number of bytes that may be written into binary
+ * @param[out] length The actual number of bytes written into binary
+ * @param[out] binaryFormat The format of the program binary
+ * @param[out] binary The actual program bytecode
+ */
+ void GetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
+
+ /**
+ * GLES extension
+ * Loads a program object with a program binary previously returned from GetProgramBinaryOES
+ * @param[in] program The program object's name/id
+ * @param[in] binaryFormat The format of the program binary
+ * @param[in] binary The program bytecode
+ * @param[in] length The number of bytes in binary
+ */
+ void ProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
+
+#endif // DALI_GLES_VERSION < 30
+
+private:
+
+ /**
+ * Lazy Initialize extensions on first use
+ */
+ void Initialize();
+
+#if DALI_GLES_VERSION < 30
+
+#ifdef PFNGLDISCARDFRAMEBUFFEREXTPROC
+ PFNGLDISCARDFRAMEBUFFEREXTPROC mGlDiscardFramebuffer;
+#endif
+
+
+#ifdef PFNGLGETPROGRAMBINARYOESPROC
+ PFNGLGETPROGRAMBINARYOESPROC mGlGetProgramBinaryOES;
+ PFNGLPROGRAMBINARYOESPROC mGlProgramBinaryOES;
+#endif
+
+#endif // DALI_GLES_VERSION < 30
+
+ bool mInitialized;
+
+};
+
+} // namespace ECoreX
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif /* __DALI_INTERNAL_GL_EXTENSION_H__ */
--- /dev/null
+#ifndef __DALI_INTERNAL_GL_IMPLEMENTATION_H__
+#define __DALI_INTERNAL_GL_IMPLEMENTATION_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#ifndef DALI_GLES_VERSION
+#error "OpenGL ES version not specified"
+#endif
+
+#if DALI_GLES_VERSION >= 30
+#include <GLES3/gl3.h>
+#else
+#include <cstdlib>
+#include <GLES2/gl2.h>
+#endif
+
+#include <dali/integration-api/gl-abstraction.h>
+
+// INTERNAL INCLUDES
+#include <gl/gl-extensions.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * GlImplementation is a concrete implementation for GlAbstraction.
+ * The class provides an OpenGL-ES 2.0 implementation.
+ * The class is provided when creating the Integration::Core object.
+ */
+class GlImplementation: public Dali::Integration::GlAbstraction
+{
+
+public:
+ virtual ~GlImplementation() {}
+
+ void PreRender()
+ {
+ /* Do nothing in main implementation */
+ }
+
+ void PostRender( unsigned int timeDelta )
+ {
+ /* Do nothing in main implementation */
+ }
+
+ /* OpenGL ES 2.0 */
+
+ void ActiveTexture (GLenum texture)
+ {
+ glActiveTexture(texture);
+ }
+
+ void AttachShader (GLuint program, GLuint shader)
+ {
+ glAttachShader(program,shader);
+ }
+
+ void BindAttribLocation (GLuint program, GLuint index, const char* name)
+ {
+ glBindAttribLocation(program,index,name);
+ }
+
+ void BindBuffer (GLenum target, GLuint buffer)
+ {
+ glBindBuffer(target,buffer);
+ }
+
+ void BindFramebuffer (GLenum target, GLuint framebuffer)
+ {
+ glBindFramebuffer(target,framebuffer);
+ }
+
+ void BindRenderbuffer (GLenum target, GLuint renderbuffer)
+ {
+ glBindRenderbuffer(target,renderbuffer);
+ }
+
+ void BindTexture (GLenum target, GLuint texture)
+ {
+ glBindTexture(target,texture);
+ }
+
+ void BlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+ {
+ glBlendColor(red,green,blue,alpha);
+ }
+
+ void BlendEquation ( GLenum mode )
+ {
+ glBlendEquation(mode);
+ }
+
+ void BlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha)
+ {
+ glBlendEquationSeparate(modeRGB,modeAlpha);
+ }
+
+ void BlendFunc (GLenum sfactor, GLenum dfactor)
+ {
+ glBlendFunc(sfactor,dfactor);
+ }
+
+ void BlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+ {
+ glBlendFuncSeparate(srcRGB,dstRGB,srcAlpha,dstAlpha);
+ }
+
+ void BufferData (GLenum target, GLsizeiptr size, const void* data, GLenum usage)
+ {
+ glBufferData(target,size,data,usage);
+ }
+
+ void BufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
+ {
+ glBufferSubData(target,offset,size,data);
+ }
+
+ GLenum CheckFramebufferStatus (GLenum target)
+ {
+ return glCheckFramebufferStatus(target);
+ }
+
+ void Clear (GLbitfield mask)
+ {
+ glClear(mask);
+ }
+
+ void ClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+ {
+ glClearColor(red,green,blue,alpha);
+ }
+
+ void ClearDepthf (GLclampf depth)
+ {
+ glClearDepthf(depth);
+ }
+
+ void ClearStencil (GLint s)
+ {
+ glClearStencil(s);
+ }
+
+ void ColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+ {
+ glColorMask(red,green,blue,alpha);
+ }
+
+ void CompileShader (GLuint shader)
+ {
+ glCompileShader(shader);
+ }
+
+ void CompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
+ {
+ glCompressedTexImage2D(target,level,internalformat,width,height,border,imageSize,data);
+ }
+
+ void CompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
+ {
+ glCompressedTexSubImage2D(target,level,xoffset,yoffset,width,height,format,imageSize,data);
+ }
+
+ void CopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+ {
+ glCopyTexImage2D(target,level,internalformat,x,y,width,height,border);
+ }
+
+ void CopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+ {
+ glCopyTexSubImage2D(target,level,xoffset,yoffset,x,y,width,height);
+ }
+
+ GLuint CreateProgram (void)
+ {
+ return glCreateProgram();
+ }
+
+ GLuint CreateShader (GLenum type)
+ {
+ return glCreateShader(type);
+ }
+
+ void CullFace (GLenum mode)
+ {
+ glCullFace(mode);
+ }
+
+ void DeleteBuffers (GLsizei n, const GLuint* buffers)
+ {
+ glDeleteBuffers(n,buffers);
+ }
+
+ void DeleteFramebuffers (GLsizei n, const GLuint* framebuffers)
+ {
+ glDeleteFramebuffers(n,framebuffers);
+ }
+
+ void DeleteProgram (GLuint program)
+ {
+ glDeleteProgram(program);
+ }
+
+ void DeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers)
+ {
+ glDeleteRenderbuffers(n,renderbuffers);
+ }
+
+ void DeleteShader (GLuint shader)
+ {
+ glDeleteShader(shader);
+ }
+
+ void DeleteTextures (GLsizei n, const GLuint* textures)
+ {
+ glDeleteTextures(n,textures);
+ }
+
+ void DepthFunc (GLenum func)
+ {
+ glDepthFunc(func);
+ }
+
+ void DepthMask (GLboolean flag)
+ {
+ glDepthMask(flag);
+ }
+
+ void DepthRangef (GLclampf zNear, GLclampf zFar)
+ {
+ glDepthRangef(zNear,zFar);
+ }
+
+ void DetachShader (GLuint program, GLuint shader)
+ {
+ glDetachShader(program,shader);
+ }
+
+ void Disable (GLenum cap)
+ {
+ glDisable(cap);
+ }
+
+ void DisableVertexAttribArray (GLuint index)
+ {
+ glDisableVertexAttribArray(index);
+ }
+
+ void DrawArrays (GLenum mode, GLint first, GLsizei count)
+ {
+ glDrawArrays(mode,first,count);
+ }
+
+ void DrawElements (GLenum mode, GLsizei count, GLenum type, const void* indices)
+ {
+ glDrawElements(mode,count,type,indices);
+ }
+
+ void Enable (GLenum cap)
+ {
+ glEnable(cap);
+ }
+
+ void EnableVertexAttribArray (GLuint index)
+ {
+ glEnableVertexAttribArray(index);
+ }
+
+ void Finish (void)
+ {
+ glFinish();
+ }
+
+ void Flush (void)
+ {
+ glFlush();
+ }
+
+ void FramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+ {
+ glFramebufferRenderbuffer(target,attachment,renderbuffertarget,renderbuffer);
+ }
+
+ void FramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+ {
+ glFramebufferTexture2D(target,attachment,textarget,texture,level);
+ }
+
+ void FrontFace (GLenum mode)
+ {
+ glFrontFace(mode);
+ }
+
+ void GenBuffers (GLsizei n, GLuint* buffers)
+ {
+ glGenBuffers(n,buffers);
+ }
+
+ void GenerateMipmap (GLenum target)
+ {
+ glGenerateMipmap(target);
+ }
+
+ void GenFramebuffers (GLsizei n, GLuint* framebuffers)
+ {
+ glGenFramebuffers(n,framebuffers);
+ }
+
+ void GenRenderbuffers (GLsizei n, GLuint* renderbuffers)
+ {
+ glGenRenderbuffers(n,renderbuffers);
+ }
+
+ void GenTextures (GLsizei n, GLuint* textures)
+ {
+ glGenTextures(n,textures);
+ }
+
+ void GetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
+ {
+ glGetActiveAttrib(program,index,bufsize,length,size,type,name);
+ }
+
+ void GetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
+ {
+ glGetActiveUniform(program,index,bufsize,length,size,type,name);
+ }
+
+ void GetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
+ {
+ glGetAttachedShaders(program,maxcount,count,shaders);
+ }
+
+ int GetAttribLocation (GLuint program, const char* name)
+ {
+ return glGetAttribLocation(program,name);
+ }
+
+ void GetBooleanv (GLenum pname, GLboolean* params)
+ {
+ glGetBooleanv(pname,params);
+ }
+
+ void GetBufferParameteriv (GLenum target, GLenum pname, GLint* params)
+ {
+ glGetBufferParameteriv(target,pname,params);
+ }
+
+ GLenum GetError (void)
+ {
+ return glGetError();
+ }
+
+ void GetFloatv (GLenum pname, GLfloat* params)
+ {
+ glGetFloatv(pname,params);
+ }
+
+ void GetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params)
+ {
+ glGetFramebufferAttachmentParameteriv(target,attachment,pname,params);
+ }
+
+ void GetIntegerv (GLenum pname, GLint* params)
+ {
+ glGetIntegerv(pname,params);
+ }
+
+ void GetProgramiv (GLuint program, GLenum pname, GLint* params)
+ {
+ glGetProgramiv(program,pname,params);
+ }
+
+ void GetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
+ {
+ glGetProgramInfoLog(program,bufsize,length,infolog);
+ }
+
+ void GetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params)
+ {
+ glGetRenderbufferParameteriv(target,pname,params);
+ }
+
+ void GetShaderiv (GLuint shader, GLenum pname, GLint* params)
+ {
+ glGetShaderiv(shader,pname,params);
+ }
+
+ void GetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
+ {
+ glGetShaderInfoLog(shader,bufsize,length,infolog);
+ }
+
+ void GetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
+ {
+ glGetShaderPrecisionFormat(shadertype,precisiontype,range,precision);
+ }
+
+ void GetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
+ {
+ glGetShaderSource(shader,bufsize,length,source);
+ }
+
+ const GLubyte* GetString (GLenum name)
+ {
+ return glGetString(name);
+ }
+
+ void GetTexParameterfv (GLenum target, GLenum pname, GLfloat* params)
+ {
+ glGetTexParameterfv(target,pname,params);
+ }
+
+ void GetTexParameteriv (GLenum target, GLenum pname, GLint* params)
+ {
+ glGetTexParameteriv(target,pname,params);
+ }
+
+ void GetUniformfv (GLuint program, GLint location, GLfloat* params)
+ {
+ glGetUniformfv(program,location,params);
+ }
+
+ void GetUniformiv (GLuint program, GLint location, GLint* params)
+ {
+ glGetUniformiv(program,location,params);
+ }
+
+ int GetUniformLocation (GLuint program, const char* name)
+ {
+ return glGetUniformLocation(program,name);
+ }
+
+ void GetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params)
+ {
+ glGetVertexAttribfv(index,pname,params);
+ }
+
+ void GetVertexAttribiv (GLuint index, GLenum pname, GLint* params)
+ {
+ glGetVertexAttribiv(index,pname,params);
+ }
+
+ void GetVertexAttribPointerv (GLuint index, GLenum pname, void** pointer)
+ {
+ glGetVertexAttribPointerv(index,pname,pointer);
+ }
+
+ void Hint (GLenum target, GLenum mode)
+ {
+ glHint(target,mode);
+ }
+
+ GLboolean IsBuffer (GLuint buffer)
+ {
+ return glIsBuffer(buffer);
+ }
+
+ GLboolean IsEnabled (GLenum cap)
+ {
+ return glIsEnabled(cap);
+ }
+
+ GLboolean IsFramebuffer (GLuint framebuffer)
+ {
+ return glIsFramebuffer(framebuffer);
+ }
+
+ GLboolean IsProgram (GLuint program)
+ {
+ return glIsProgram(program);
+ }
+
+ GLboolean IsRenderbuffer (GLuint renderbuffer)
+ {
+ return glIsRenderbuffer(renderbuffer);
+ }
+
+ GLboolean IsShader (GLuint shader)
+ {
+ return glIsShader(shader);
+ }
+
+ GLboolean IsTexture (GLuint texture)
+ {
+ return glIsTexture(texture);
+ }
+
+ void LineWidth (GLfloat width)
+ {
+ glLineWidth(width);
+ }
+
+ void LinkProgram (GLuint program)
+ {
+ glLinkProgram(program);
+ }
+
+ void PixelStorei (GLenum pname, GLint param)
+ {
+ glPixelStorei(pname,param);
+ }
+
+ void PolygonOffset (GLfloat factor, GLfloat units)
+ {
+ glPolygonOffset(factor,units);
+ }
+
+ void ReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
+ {
+ glReadPixels(x,y,width,height,format,type,pixels);
+ }
+
+ void ReleaseShaderCompiler (void)
+ {
+ glReleaseShaderCompiler();
+ }
+
+ void RenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+ {
+ glRenderbufferStorage(target,internalformat,width,height);
+ }
+
+ void SampleCoverage (GLclampf value, GLboolean invert)
+ {
+ glSampleCoverage(value,invert);
+ }
+
+ void Scissor (GLint x, GLint y, GLsizei width, GLsizei height)
+ {
+ glScissor(x,y,width,height);
+ }
+
+ void ShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
+ {
+ glShaderBinary(n,shaders,binaryformat,binary,length);
+ }
+
+ void ShaderSource (GLuint shader, GLsizei count, const char** string, const GLint* length)
+ {
+ glShaderSource(shader,count,string,length);
+ }
+
+ void StencilFunc (GLenum func, GLint ref, GLuint mask)
+ {
+ glStencilFunc(func,ref,mask);
+ }
+
+ void StencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask)
+ {
+ glStencilFuncSeparate(face,func,ref,mask);
+ }
+
+ void StencilMask (GLuint mask)
+ {
+ glStencilMask(mask);
+ }
+
+ void StencilMaskSeparate (GLenum face, GLuint mask)
+ {
+ glStencilMaskSeparate(face,mask);
+ }
+
+ void StencilOp (GLenum fail, GLenum zfail, GLenum zpass)
+ {
+ glStencilOp(fail,zfail,zpass);
+ }
+
+ void StencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+ {
+ glStencilOpSeparate(face,fail,zfail,zpass);
+ }
+
+ void TexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
+ {
+ glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);
+ }
+
+ void TexParameterf (GLenum target, GLenum pname, GLfloat param)
+ {
+ glTexParameterf(target,pname,param);
+ }
+
+ void TexParameterfv (GLenum target, GLenum pname, const GLfloat* params)
+ {
+ glTexParameterfv(target,pname,params);
+ }
+
+ void TexParameteri (GLenum target, GLenum pname, GLint param)
+ {
+ glTexParameteri(target,pname,param);
+ }
+
+ void TexParameteriv (GLenum target, GLenum pname, const GLint* params)
+ {
+ glTexParameteriv(target,pname,params);
+ }
+
+ void TexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
+ {
+ glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels);
+ }
+
+ void Uniform1f (GLint location, GLfloat x)
+ {
+ glUniform1f(location,x);
+ }
+
+ void Uniform1fv (GLint location, GLsizei count, const GLfloat* v)
+ {
+ glUniform1fv(location,count,v);
+ }
+
+ void Uniform1i (GLint location, GLint x)
+ {
+ glUniform1i(location,x);
+ }
+
+ void Uniform1iv (GLint location, GLsizei count, const GLint* v)
+ {
+ glUniform1iv(location,count,v);
+ }
+
+ void Uniform2f (GLint location, GLfloat x, GLfloat y)
+ {
+ glUniform2f(location,x,y);
+ }
+
+ void Uniform2fv (GLint location, GLsizei count, const GLfloat* v)
+ {
+ glUniform2fv(location,count,v);
+ }
+
+ void Uniform2i (GLint location, GLint x, GLint y)
+ {
+ glUniform2i(location,x,y);
+ }
+
+ void Uniform2iv (GLint location, GLsizei count, const GLint* v)
+ {
+ glUniform2iv(location,count,v);
+ }
+
+ void Uniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z)
+ {
+ glUniform3f(location,x,y,z);
+ }
+
+ void Uniform3fv (GLint location, GLsizei count, const GLfloat* v)
+ {
+ glUniform3fv(location,count,v);
+ }
+
+ void Uniform3i (GLint location, GLint x, GLint y, GLint z)
+ {
+ glUniform3i(location,x,y,z);
+ }
+
+ void Uniform3iv (GLint location, GLsizei count, const GLint* v)
+ {
+ glUniform3iv(location,count,v);
+ }
+
+ void Uniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+ {
+ glUniform4f(location,x,y,z,w);
+ }
+
+ void Uniform4fv (GLint location, GLsizei count, const GLfloat* v)
+ {
+ glUniform4fv(location,count,v);
+ }
+
+ void Uniform4i (GLint location, GLint x, GLint y, GLint z, GLint w)
+ {
+ glUniform4i(location,x,y,z,w);
+ }
+
+ void Uniform4iv (GLint location, GLsizei count, const GLint* v)
+ {
+ glUniform4iv(location,count,v);
+ }
+
+ void UniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+ {
+ glUniformMatrix2fv(location,count,transpose,value);
+ }
+
+ void UniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+ {
+ glUniformMatrix3fv(location,count,transpose,value);
+ }
+
+ void UniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+ {
+ glUniformMatrix4fv(location,count,transpose,value);
+ }
+
+ void UseProgram (GLuint program)
+ {
+ glUseProgram(program);
+ }
+
+ void ValidateProgram (GLuint program)
+ {
+ glValidateProgram(program);
+ }
+
+ void VertexAttrib1f (GLuint indx, GLfloat x)
+ {
+ glVertexAttrib1f(indx,x);
+ }
+
+ void VertexAttrib1fv (GLuint indx, const GLfloat* values)
+ {
+ glVertexAttrib1fv(indx,values);
+ }
+
+ void VertexAttrib2f (GLuint indx, GLfloat x, GLfloat y)
+ {
+ glVertexAttrib2f(indx,x,y);
+ }
+
+ void VertexAttrib2fv (GLuint indx, const GLfloat* values)
+ {
+ glVertexAttrib2fv(indx,values);
+ }
+
+ void VertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z)
+ {
+ glVertexAttrib3f(indx,x,y,z);
+ }
+
+ void VertexAttrib3fv (GLuint indx, const GLfloat* values)
+ {
+ glVertexAttrib3fv(indx,values);
+ }
+
+ void VertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+ {
+ glVertexAttrib4f(indx,x,y,z,w);
+ }
+
+ void VertexAttrib4fv (GLuint indx, const GLfloat* values)
+ {
+ glVertexAttrib4fv(indx,values);
+ }
+
+ void VertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
+ {
+ glVertexAttribPointer(indx,size,type,normalized,stride,ptr);
+ }
+
+ void Viewport (GLint x, GLint y, GLsizei width, GLsizei height)
+ {
+ glViewport(x,y,width,height);
+ }
+
+ /* OpenGL ES 3.0 */
+
+ void ReadBuffer(GLenum mode)
+ {
+#if DALI_GLES_VERSION >= 30
+ glReadBuffer(mode);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
+ {
+#if DALI_GLES_VERSION >= 30
+ glDrawRangeElements(mode,start,end,count,type,indices);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+ {
+#if DALI_GLES_VERSION >= 30
+ glTexImage3D(target,level,internalformat,width,height,depth,border,format,type,pixels);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
+ {
+#if DALI_GLES_VERSION >= 30
+ glTexSubImage3D(target,level,xoffset,yoffset,zoffset,width,height,depth,format,type,pixels);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+ {
+#if DALI_GLES_VERSION >= 30
+ glCopyTexSubImage3D(target,level,xoffset,yoffset,zoffset,x,y,width,height);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
+ {
+#if DALI_GLES_VERSION >= 30
+ glCompressedTexImage3D(target,level,internalformat,width,height,depth,border,imageSize,data);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
+ {
+#if DALI_GLES_VERSION >= 30
+ glCompressedTexSubImage3D(target,level,xoffset,yoffset,zoffset,width,height,depth,format,imageSize,data);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GenQueries(GLsizei n, GLuint* ids)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGenQueries(n,ids);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void DeleteQueries(GLsizei n, const GLuint* ids)
+ {
+#if DALI_GLES_VERSION >= 30
+ glDeleteQueries(n,ids);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ GLboolean IsQuery(GLuint id)
+ {
+#if DALI_GLES_VERSION >= 30
+ return glIsQuery(id);
+#else
+ return 0;
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void BeginQuery(GLenum target, GLuint id)
+ {
+#if DALI_GLES_VERSION >= 30
+ glBeginQuery(target,id);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void EndQuery(GLenum target)
+ {
+#if DALI_GLES_VERSION >= 30
+ glEndQuery(target);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetQueryiv(GLenum target, GLenum pname, GLint* params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetQueryiv(target,pname,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetQueryObjectuiv(id,pname,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ GLboolean UnmapBuffer(GLenum target)
+ {
+#if DALI_GLES_VERSION >= 30
+ return glUnmapBuffer(target);
+#else
+ return 0;
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetBufferPointerv(target,pname,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void DrawBuffers(GLsizei n, const GLenum* bufs)
+ {
+#if DALI_GLES_VERSION >= 30
+ glDrawBuffers(n,bufs);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniformMatrix2x3fv(location,count,transpose,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniformMatrix3x2fv(location,count,transpose,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniformMatrix2x4fv(location,count,transpose,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniformMatrix4x2fv(location,count,transpose,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniformMatrix3x4fv(location,count,transpose,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniformMatrix4x3fv(location,count,transpose,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
+ {
+#if DALI_GLES_VERSION >= 30
+ glBlitFramebuffer(srcX0,srcY0,srcX1,srcY1,dstX0,dstY0,dstX1,dstY1,mask,filter);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+ {
+#if DALI_GLES_VERSION >= 30
+ glRenderbufferStorageMultisample(target,samples,internalformat,width,height);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
+ {
+#if DALI_GLES_VERSION >= 30
+ glFramebufferTextureLayer(target,attachment,texture,level,layer);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
+ {
+#if DALI_GLES_VERSION >= 30
+ return glMapBufferRange(target,offset,length,access);
+#else
+ return NULL;
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
+ {
+#if DALI_GLES_VERSION >= 30
+ glFlushMappedBufferRange(target,offset,length);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void BindVertexArray(GLuint array)
+ {
+#if DALI_GLES_VERSION >= 30
+ glBindVertexArray(array);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
+ {
+#if DALI_GLES_VERSION >= 30
+ glDeleteVertexArrays(n,arrays);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GenVertexArrays(GLsizei n, GLuint* arrays)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGenVertexArrays(n,arrays);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ GLboolean IsVertexArray(GLuint array)
+ {
+#if DALI_GLES_VERSION >= 30
+ return glIsVertexArray(array);
+#else
+ return 0;
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetIntegeri_v(target,index,data);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void BeginTransformFeedback(GLenum primitiveMode)
+ {
+#if DALI_GLES_VERSION >= 30
+ glBeginTransformFeedback(primitiveMode);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void EndTransformFeedback(void)
+ {
+#if DALI_GLES_VERSION >= 30
+ glEndTransformFeedback();
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
+ {
+#if DALI_GLES_VERSION >= 30
+ glBindBufferRange(target,index,buffer,offset,size);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
+ {
+#if DALI_GLES_VERSION >= 30
+ glBindBufferBase(target,index,buffer);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
+ {
+#if DALI_GLES_VERSION >= 30
+ glTransformFeedbackVaryings(program,count,varyings,bufferMode);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetTransformFeedbackVarying(program,index,bufSize,length,size,type,name);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
+ {
+#if DALI_GLES_VERSION >= 30
+ glVertexAttribIPointer(index,size,type,stride,pointer);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetVertexAttribIiv(index,pname,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetVertexAttribIuiv(index,pname,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
+ {
+#if DALI_GLES_VERSION >= 30
+ glVertexAttribI4i(index,x,y,z,w);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
+ {
+#if DALI_GLES_VERSION >= 30
+ glVertexAttribI4ui(index,x,y,z,w);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void VertexAttribI4iv(GLuint index, const GLint* v)
+ {
+#if DALI_GLES_VERSION >= 30
+ glVertexAttribI4iv(index,v);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void VertexAttribI4uiv(GLuint index, const GLuint* v)
+ {
+#if DALI_GLES_VERSION >= 30
+ glVertexAttribI4uiv(index,v);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetUniformuiv(GLuint program, GLint location, GLuint* params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetUniformuiv(program,location,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ GLint GetFragDataLocation(GLuint program, const GLchar *name)
+ {
+#if DALI_GLES_VERSION >= 30
+ return glGetFragDataLocation(program,name);
+#else
+ return -1;
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void Uniform1ui(GLint location, GLuint v0)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniform1ui(location,v0);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void Uniform2ui(GLint location, GLuint v0, GLuint v1)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniform2ui(location,v0,v1);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniform3ui(location,v0,v1,v2);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniform4ui(location,v0,v1,v2,v3);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniform1uiv(location,count,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniform2uiv(location,count,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniform3uiv(location,count,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniform4uiv(location,count,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glClearBufferiv(buffer,drawbuffer,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glClearBufferuiv(buffer,drawbuffer,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glClearBufferfv(buffer,drawbuffer,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
+ {
+#if DALI_GLES_VERSION >= 30
+ glClearBufferfi(buffer,drawbuffer,depth,stencil);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ const GLubyte* GetStringi(GLenum name, GLuint index)
+ {
+#if DALI_GLES_VERSION >= 30
+ return glGetStringi(name,index);
+#else
+ return NULL;
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
+ {
+#if DALI_GLES_VERSION >= 30
+ glCopyBufferSubData(readTarget,writeTarget,readOffset,writeOffset,size);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetUniformIndices(program,uniformCount,uniformNames,uniformIndices);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetActiveUniformsiv(program,uniformCount,uniformIndices,pname,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
+ {
+#if DALI_GLES_VERSION >= 30
+ return glGetUniformBlockIndex(program,uniformBlockName);
+#else
+ return 0;
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetActiveUniformBlockiv(program,uniformBlockIndex,pname,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetActiveUniformBlockName(program,uniformBlockIndex,bufSize,length,uniformBlockName);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
+ {
+#if DALI_GLES_VERSION >= 30
+ glUniformBlockBinding(program,uniformBlockIndex,uniformBlockBinding);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
+ {
+#if DALI_GLES_VERSION >= 30
+ glDrawArraysInstanced(mode,first,count,instanceCount);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
+ {
+#if DALI_GLES_VERSION >= 30
+ glDrawElementsInstanced(mode,count,type,indices,instanceCount);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ GLsync FenceSync(GLenum condition, GLbitfield flags)
+ {
+#if DALI_GLES_VERSION >= 30
+ return glFenceSync(condition,flags);
+#else
+ return NULL;
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ GLboolean IsSync(GLsync sync)
+ {
+#if DALI_GLES_VERSION >= 30
+ return glIsSync(sync);
+#else
+ return 0;
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void DeleteSync(GLsync sync)
+ {
+#if DALI_GLES_VERSION >= 30
+ glDeleteSync(sync);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
+ {
+#if DALI_GLES_VERSION >= 30
+ return glClientWaitSync(sync,flags,timeout);
+#else
+ return 0;
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
+ {
+#if DALI_GLES_VERSION >= 30
+ glWaitSync(sync,flags,timeout);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetInteger64v(GLenum pname, GLint64* params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetInteger64v(pname,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetSynciv(sync,pname,bufSize,length,values);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetInteger64i_v(target,index,data);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetBufferParameteri64v(target,pname,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GenSamplers(GLsizei count, GLuint* samplers)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGenSamplers(count,samplers);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void DeleteSamplers(GLsizei count, const GLuint* samplers)
+ {
+#if DALI_GLES_VERSION >= 30
+ glDeleteSamplers(count,samplers);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ GLboolean IsSampler(GLuint sampler)
+ {
+#if DALI_GLES_VERSION >= 30
+ return glIsSampler(sampler);
+#else
+ return 0;
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void BindSampler(GLuint unit, GLuint sampler)
+ {
+#if DALI_GLES_VERSION >= 30
+ glBindSampler(unit,sampler);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
+ {
+#if DALI_GLES_VERSION >= 30
+ glSamplerParameteri(sampler,pname,param);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
+ {
+#if DALI_GLES_VERSION >= 30
+ glSamplerParameteriv(sampler,pname,param);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
+ {
+#if DALI_GLES_VERSION >= 30
+ glSamplerParameterf(sampler,pname,param);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
+ {
+#if DALI_GLES_VERSION >= 30
+ glSamplerParameterfv(sampler,pname,param);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetSamplerParameteriv(sampler,pname,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetSamplerParameterfv(sampler,pname,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void VertexAttribDivisor(GLuint index, GLuint divisor)
+ {
+#if DALI_GLES_VERSION >= 30
+ glVertexAttribDivisor(index,divisor);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void BindTransformFeedback(GLenum target, GLuint id)
+ {
+#if DALI_GLES_VERSION >= 30
+ glBindTransformFeedback(target,id);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
+ {
+#if DALI_GLES_VERSION >= 30
+ glDeleteTransformFeedbacks(n,ids);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GenTransformFeedbacks(GLsizei n, GLuint* ids)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGenTransformFeedbacks(n,ids);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ GLboolean IsTransformFeedback(GLuint id)
+ {
+#if DALI_GLES_VERSION >= 30
+ return glIsTransformFeedback(id);
+#else
+ return 0;
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void PauseTransformFeedback(void)
+ {
+#if DALI_GLES_VERSION >= 30
+ glPauseTransformFeedback();
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void ResumeTransformFeedback(void)
+ {
+#if DALI_GLES_VERSION >= 30
+ glResumeTransformFeedback();
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
+ {
+#if DALI_GLES_VERSION >= 30
+ // if OpenGL ES 2.0 compatibility is need this can be implemented with
+ // glGetProgramBinaryOES
+ glGetProgramBinary(program,bufSize,length,binaryFormat,binary);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
+ {
+#if DALI_GLES_VERSION >= 30
+ // if OpenGL ES 2.0 compatibility is need this can be implemented with
+ // glProgramBinaryOES
+ glProgramBinary(program,binaryFormat,binary,length);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void ProgramParameteri(GLuint program, GLenum pname, GLint value)
+ {
+#if DALI_GLES_VERSION >= 30
+ glProgramParameteri(program,pname,value);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
+ {
+#if DALI_GLES_VERSION >= 30
+ // if OpenGL ES 2.0 compatibility is need this can be implemented with
+ // glDiscardFramebufferEXT
+ glInvalidateFramebuffer(target,numAttachments,attachments);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
+ {
+#if DALI_GLES_VERSION >= 30
+ glInvalidateSubFramebuffer(target,numAttachments,attachments,x,y,width,height);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
+ {
+#if DALI_GLES_VERSION >= 30
+ glTexStorage2D(target,levels,internalformat,width,height);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
+ {
+#if DALI_GLES_VERSION >= 30
+ glTexStorage3D(target,levels,internalformat,width,height,depth);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+ void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
+ {
+#if DALI_GLES_VERSION >= 30
+ glGetInternalformativ(target,internalformat,pname,bufSize,params);
+#endif // DALI_GLES_VERSION >= 30
+ }
+
+private:
+ ECoreX::GlExtensions mGlExtensions;
+
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_GL_IMPLEMENTATION_H__
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// CLASS HEADER
+#include "gl-proxy-implementation.h"
+
+// EXTERNAL INCLUDES
+#include <math.h>
+
+// INTERNAL INCLUDES
+#include <base/environment-options.h>
+#include <dali/integration-api/debug.h>
+
+namespace
+{
+const int NUM_FRAMES_PER_SECOND(60);
+}
+
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+Sampler::Sampler( const char* description )
+: mDescription( description ),
+ mAccumulated(0.0f),
+ mAccumulatedSquare(0.0f),
+ mMin(0.0f),
+ mMax(0.0f),
+ mNumSamples(0),
+ mCurrentFrameCount(0)
+{
+}
+
+void Sampler::Increment()
+{
+ mCurrentFrameCount++;
+}
+
+void Sampler::Reset()
+{
+ mAccumulated = 0.0f;
+ mAccumulatedSquare= 0.0f;
+ mMin = 0.0f;
+ mMax = 0.0f;
+ mNumSamples = 0;
+ mCurrentFrameCount = 0;
+}
+
+void Sampler::Accumulate()
+{
+ if( mNumSamples == 0 )
+ {
+ mMin = mCurrentFrameCount;
+ mMax = mCurrentFrameCount;
+ }
+ else
+ {
+ if(mCurrentFrameCount < mMin)
+ {
+ mMin = mCurrentFrameCount;
+ }
+ if(mCurrentFrameCount > mMax)
+ {
+ mMax = mCurrentFrameCount;
+ }
+ }
+
+ mNumSamples++;
+
+ mAccumulated += mCurrentFrameCount;
+ mAccumulatedSquare += (mCurrentFrameCount * mCurrentFrameCount);
+ mCurrentFrameCount = 0;
+}
+const char* Sampler::GetDescription() const
+{
+ return mDescription;
+}
+
+float Sampler::GetMeanValue() const
+{
+ float meanValue = 0;
+ if( mNumSamples > 0 )
+ {
+ meanValue = mAccumulated / (float)mNumSamples;
+ }
+ return meanValue;
+}
+
+float Sampler::GetStandardDeviation() const
+{
+ float standardDeviation=0.0f;
+ if( mNumSamples > 0 )
+ {
+ standardDeviation = sqrtf( mNumSamples * mAccumulatedSquare - (mAccumulated*mAccumulated)) / mNumSamples;
+ }
+ return standardDeviation;
+}
+
+float Sampler::GetMin() const
+{
+ return mMin;
+}
+
+float Sampler::GetMax() const
+{
+ return mMax;
+}
+
+GlProxyImplementation::GlProxyImplementation(EnvironmentOptions& environmentOptions)
+: mEnvironmentOptions(environmentOptions),
+ mClearSampler("Clear calls"),
+ mBindBufferSampler( "Bind buffers"),
+ mBindTextureSampler( "Bind textures"),
+ mDrawSampler("Draw calls"),
+ mUniformSampler("Uniform sets"),
+ mUseProgramSampler("Used programs"),
+ mDrawCount(0),
+ mUniformCount(0),
+ mFrameCount(0)
+{
+}
+
+GlProxyImplementation::~GlProxyImplementation()
+{
+}
+
+void GlProxyImplementation::PreRender()
+{
+}
+
+void GlProxyImplementation::PostRender( unsigned int timeDelta )
+{
+ // Accumulate counts in each sampler
+ AccumulateSamples();
+
+ // When we reach the desired frame count, output the averages from the samples
+ mFrameCount++;
+ if( mFrameCount >= mEnvironmentOptions.GetGlesCallTime() * NUM_FRAMES_PER_SECOND )
+ {
+ LogResults();
+ ResetSamplers();
+ }
+}
+
+void GlProxyImplementation::Clear( GLbitfield mask )
+{
+ mClearSampler.Increment();
+ GlImplementation::Clear(mask);
+}
+
+void GlProxyImplementation::BindBuffer( GLenum target, GLuint buffer )
+{
+ mBindBufferSampler.Increment();
+ GlImplementation::BindBuffer(target,buffer);
+}
+
+void GlProxyImplementation::BindTexture( GLenum target, GLuint texture )
+{
+ mBindTextureSampler.Increment();
+ GlImplementation::BindTexture(target,texture);
+}
+
+void GlProxyImplementation::DrawArrays( GLenum mode, GLint first, GLsizei count )
+{
+ mDrawSampler.Increment();
+ GlImplementation::DrawArrays(mode,first,count);
+}
+
+void GlProxyImplementation::DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices )
+{
+ mDrawSampler.Increment();
+ GlImplementation::DrawElements(mode,count,type,indices);
+}
+
+void GlProxyImplementation::Uniform1f( GLint location, GLfloat x )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform1f(location,x);
+}
+
+void GlProxyImplementation::Uniform1fv( GLint location, GLsizei count, const GLfloat* v )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform1fv(location,count,v);
+}
+
+void GlProxyImplementation::Uniform1i( GLint location, GLint x )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform1i(location,x);
+}
+
+void GlProxyImplementation::Uniform1iv( GLint location, GLsizei count, const GLint* v )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform1iv(location,count,v);
+}
+
+void GlProxyImplementation::Uniform2f( GLint location, GLfloat x, GLfloat y)
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform2f(location,x,y);
+}
+
+void GlProxyImplementation::Uniform2fv( GLint location, GLsizei count, const GLfloat* v )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform2fv(location,count,v);
+}
+
+void GlProxyImplementation::Uniform2i( GLint location, GLint x, GLint y )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform2i(location,x,y);
+}
+
+void GlProxyImplementation::Uniform2iv( GLint location, GLsizei count, const GLint* v )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform2iv(location,count,v);
+}
+
+void GlProxyImplementation::Uniform3f( GLint location, GLfloat x, GLfloat y, GLfloat z)
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform3f(location,x,y,z);
+}
+
+void GlProxyImplementation::Uniform3fv( GLint location, GLsizei count, const GLfloat* v )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform3fv(location,count,v);
+}
+
+void GlProxyImplementation::Uniform3i( GLint location, GLint x, GLint y, GLint z )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform3i(location,x,y,z);
+}
+
+void GlProxyImplementation::Uniform3iv( GLint location, GLsizei count, const GLint* v )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform3iv(location,count,v);
+}
+
+void GlProxyImplementation::Uniform4f( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform4f(location,x,y,z,w);
+}
+
+void GlProxyImplementation::Uniform4fv( GLint location, GLsizei count, const GLfloat* v )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform4fv(location,count,v);
+}
+
+void GlProxyImplementation::Uniform4i( GLint location, GLint x, GLint y, GLint z, GLint w )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform4i(location,x,y,z,w);
+}
+
+void GlProxyImplementation::Uniform4iv( GLint location, GLsizei count, const GLint* v )
+{
+ mUniformSampler.Increment();
+ GlImplementation::Uniform4iv(location,count,v);
+}
+
+void GlProxyImplementation::UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
+{
+ mUniformSampler.Increment();
+ GlImplementation::UniformMatrix2fv(location,count,transpose,value);
+}
+
+void GlProxyImplementation::UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
+{
+ mUniformSampler.Increment();
+ GlImplementation::UniformMatrix3fv(location,count,transpose,value);
+}
+
+void GlProxyImplementation::UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
+{
+ mUniformSampler.Increment();
+ GlImplementation::UniformMatrix4fv(location,count,transpose,value);
+}
+
+void GlProxyImplementation::UseProgram( GLuint program )
+{
+ mUseProgramSampler.Increment();
+ GlImplementation::UseProgram(program);
+}
+
+void GlProxyImplementation::AccumulateSamples()
+{
+ // Accumulate counts in each sampler
+ mClearSampler.Accumulate();
+ mBindBufferSampler.Accumulate();
+ mBindTextureSampler.Accumulate();
+ mDrawSampler.Accumulate();
+ mUniformSampler.Accumulate();
+ mUseProgramSampler.Accumulate();
+}
+
+void GlProxyImplementation::LogResults()
+{
+ Debug::LogMessage( Debug::DebugInfo, "OpenGL ES statistics sampled over %d frames) operations per frame:\n", mFrameCount );
+ LogCalls( mClearSampler );
+ LogCalls( mBindBufferSampler );
+ LogCalls( mBindTextureSampler );
+ LogCalls( mDrawSampler );
+ LogCalls( mUniformSampler );
+ LogCalls( mUseProgramSampler );
+}
+
+void GlProxyImplementation::LogCalls( const Sampler& sampler )
+{
+ Debug::LogMessage( Debug::DebugInfo, " %s : Mean %5.2f (Min:%5.2f, Max:%5.2f, StdDev:%5.2f)\n",
+ sampler.GetDescription(),
+ sampler.GetMeanValue(), sampler.GetMin(), sampler.GetMax(),
+ sampler.GetStandardDeviation() );
+}
+
+void GlProxyImplementation::ResetSamplers()
+{
+ mClearSampler.Reset();
+ mBindBufferSampler.Reset();
+ mBindTextureSampler.Reset();
+ mDrawSampler.Reset();
+ mUniformSampler.Reset();
+ mUseProgramSampler.Reset();
+ mFrameCount = 0;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H__
+#define __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+#include <gl/gl-implementation.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class EnvironmentOptions;
+
+/**
+ * Helper class to calculate the statistics for Open GLES calls
+ */
+class Sampler
+{
+public:
+
+ /**
+ * Constructor
+ * @param description to write to the log
+ */
+ Sampler( const char* description );
+
+ /**
+ * Increment the counter for this frame
+ */
+ void Increment();
+
+ /**
+ * Reset the counter
+ */
+ void Reset();
+
+ /**
+ * Accumulate the count onto statistics
+ */
+ void Accumulate();
+
+ /**
+ * @return the description of the sampler
+ */
+ const char* GetDescription() const;
+
+ /**
+ * @return the mean value
+ */
+ float GetMeanValue() const;
+
+ /**
+ * @return the standard deviation
+ */
+ float GetStandardDeviation() const;
+
+ /**
+ * @return the minimum value
+ */
+ float GetMin() const;
+
+ /**
+ * @return the maximum value
+ */
+ float GetMax() const;
+
+private: // Data
+
+ const char* mDescription;
+ float mAccumulated;
+ float mAccumulatedSquare;
+ float mMin;
+ float mMax;
+ unsigned int mNumSamples;
+ unsigned int mCurrentFrameCount;
+};
+
+/**
+ * GlProxyImplementation is a wrapper for the concrete implementation
+ * of GlAbstraction that also gathers statistical information.
+ */
+class GlProxyImplementation : public GlImplementation
+{
+public:
+
+ /**
+ * Constructor
+ * @param environmentOptions to check how often to log results
+ */
+ GlProxyImplementation(EnvironmentOptions& environmentOptions);
+
+ /**
+ * Virtual destructor
+ */
+ virtual ~GlProxyImplementation();
+
+ /**
+ * @copydoc GlAbstraction::PreRender();
+ */
+ virtual void PreRender();
+
+ /**
+ * @copydoc GlAbstraction::PostRender();
+ */
+ virtual void PostRender( unsigned int timeDelta );
+
+ /* OpenGL ES 2.0 API */
+ virtual void Clear( GLbitfield mask );
+
+ virtual void BindBuffer( GLenum target, GLuint buffer );
+ virtual void BindTexture( GLenum target, GLuint texture );
+
+ virtual void DrawArrays( GLenum mode, GLint first, GLsizei count );
+ virtual void DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices );
+
+ virtual void Uniform1f ( GLint location, GLfloat x );
+ virtual void Uniform1fv( GLint location, GLsizei count, const GLfloat* v );
+ virtual void Uniform1i ( GLint location, GLint x );
+ virtual void Uniform1iv( GLint location, GLsizei count, const GLint* v );
+ virtual void Uniform2f ( GLint location, GLfloat x, GLfloat y );
+ virtual void Uniform2fv( GLint location, GLsizei count, const GLfloat* v );
+ virtual void Uniform2i ( GLint location, GLint x, GLint y );
+ virtual void Uniform2iv( GLint location, GLsizei count, const GLint* v );
+ virtual void Uniform3f ( GLint location, GLfloat x, GLfloat y, GLfloat z );
+ virtual void Uniform3fv( GLint location, GLsizei count, const GLfloat* v );
+ virtual void Uniform3i ( GLint location, GLint x, GLint y, GLint z );
+ virtual void Uniform3iv( GLint location, GLsizei count, const GLint* v );
+ virtual void Uniform4f ( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+ virtual void Uniform4fv( GLint location, GLsizei count, const GLfloat* v );
+ virtual void Uniform4i ( GLint location, GLint x, GLint y, GLint z, GLint w );
+ virtual void Uniform4iv( GLint location, GLsizei count, const GLint* v );
+ virtual void UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
+ virtual void UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
+ virtual void UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
+
+ virtual void UseProgram( GLuint program );
+
+private: // Helpers
+
+ void AccumulateSamples();
+ void LogResults();
+ void LogCalls( const Sampler& sampler );
+ void ResetSamplers();
+
+private: // Data
+
+ EnvironmentOptions& mEnvironmentOptions;
+ Sampler mClearSampler;
+ Sampler mBindBufferSampler;
+ Sampler mBindTextureSampler;
+ Sampler mDrawSampler;
+ Sampler mUniformSampler;
+ Sampler mUseProgramSampler;
+ int mDrawCount;
+ int mUniformCount;
+ int mFrameCount;
+
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <haptic-player-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <adaptor-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace // unnamed namespace
+{
+
+// Type Registration
+Dali::BaseHandle Create()
+{
+ return HapticPlayer::Get();
+}
+
+Dali::TypeRegistration HAPTIC_PLAYER_TYPE( typeid(Dali::HapticPlayer), typeid(Dali::BaseHandle), Create );
+
+} // unnamed namespace
+
+Dali::HapticPlayer HapticPlayer::New()
+{
+ Dali::HapticPlayer player = Dali::HapticPlayer( new HapticPlayer() );
+ return player;
+}
+
+Dali::HapticPlayer HapticPlayer::Get()
+{
+ Dali::HapticPlayer player;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::HapticPlayer ) );
+ if ( handle )
+ {
+ // If so, downcast the handle
+ player = Dali::HapticPlayer( dynamic_cast< HapticPlayer* >( handle.GetObjectPtr() ) );
+ }
+ else
+ {
+ Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
+ player = Dali::HapticPlayer( New() );
+ adaptorImpl.RegisterSingleton( typeid( player ), player );
+ }
+ }
+
+ return player;
+}
+
+void HapticPlayer::PlayMonotone( unsigned int duration )
+{
+ mPlugin.PlayHapticMonotone( duration );
+}
+
+void HapticPlayer::PlayFile( const std::string& filePath )
+{
+ mPlugin.PlayHaptic( filePath );
+}
+
+void HapticPlayer::Stop()
+{
+ mPlugin.StopHaptic();
+}
+
+HapticPlayer::HapticPlayer()
+: mPlugin( FeedbackPluginProxy::DEFAULT_OBJECT_NAME )
+{
+}
+
+HapticPlayer::~HapticPlayer()
+{
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_HAPTIC_PLAYER_H__
+#define __DALI_INTERNAL_HAPTIC_PLAYER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/public-api/object/base-object.h>
+#include <haptic-player.h>
+
+// INTERNAL INCLUDES
+#include <feedback/feedback-plugin-proxy.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class FeedbackPluginProxy;
+
+/**
+ * Plays haptic effects.
+ */
+class HapticPlayer : public Dali::BaseObject
+{
+
+public:
+
+ /**
+ * Create a HapticPlayer.
+ * This should only be called once by the Adaptor class.
+ * @return A newly created HapticPlayer.
+ */
+ static Dali::HapticPlayer New();
+
+ /**
+ * Retrieve a handle to the HapticPlayer. This creates an instance if none has been created.
+ * @return A handle to the HapticPlayer.
+ */
+ static Dali::HapticPlayer Get();
+
+ /**
+ * @copydoc Dali::HapticPlayer::PlayMonotone()
+ */
+ void PlayMonotone(unsigned int duration);
+
+ /**
+ * @copydoc Dali::HapticPlayer::PlayFile()
+ */
+ void PlayFile( const std::string& filePath );
+
+ /**
+ * @copydoc Dali::HapticPlayer::Stop()
+ */
+ void Stop();
+
+private:
+
+ /**
+ * Private Constructor; see also HapticPlayer::New()
+ */
+ HapticPlayer();
+
+ /**
+ * Virtual Destructor
+ */
+ virtual ~HapticPlayer();
+
+ // Undefined
+ HapticPlayer(const HapticPlayer&);
+
+ // Undefined
+ HapticPlayer& operator=(HapticPlayer&);
+
+private:
+
+ FeedbackPluginProxy mPlugin;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Internal::Adaptor::HapticPlayer& GetImplementation(Dali::HapticPlayer& player)
+{
+ DALI_ASSERT_ALWAYS( player && "HapticPlayer handle is empty" );
+
+ BaseObject& handle = player.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::HapticPlayer&>(handle);
+}
+
+inline const Internal::Adaptor::HapticPlayer& GetImplementation(const Dali::HapticPlayer& player)
+{
+ DALI_ASSERT_ALWAYS( player && "HapticPlayer handle is empty" );
+
+ const BaseObject& handle = player.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::HapticPlayer&>(handle);
+}
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_HAPTIC_PLAYER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <haptic-player.h>
+
+// INTERNAL INCLUDES
+#include <haptic-player-impl.h>
+
+namespace Dali
+{
+
+HapticPlayer::HapticPlayer()
+{
+}
+
+HapticPlayer HapticPlayer::Get()
+{
+ return Internal::Adaptor::HapticPlayer::Get();
+}
+
+HapticPlayer::~HapticPlayer()
+{
+}
+
+void HapticPlayer::PlayMonotone(unsigned int duration)
+{
+ GetImplementation(*this).PlayMonotone(duration);
+}
+
+void HapticPlayer::PlayFile(const std::string filePath)
+{
+ GetImplementation(*this).PlayFile(filePath);
+}
+
+void HapticPlayer::Stop()
+{
+ GetImplementation(*this).Stop();
+}
+
+HapticPlayer::HapticPlayer( Internal::Adaptor::HapticPlayer* player )
+: BaseHandle( player )
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <imf-manager.h>
+
+// INTERNAL INCLUDES
+#include <imf-manager-impl.h>
+#include <adaptor-impl.h>
+
+namespace Dali
+{
+
+ImfManager::ImfManager()
+{
+}
+
+ImfManager::~ImfManager()
+{
+}
+
+ImfManager ImfManager::Get()
+{
+ return Internal::Adaptor::ImfManager::Get();
+}
+
+ImfContext ImfManager::GetContext()
+{
+ return reinterpret_cast<ImfContext>( Internal::Adaptor::ImfManager::GetImplementation(*this).GetContext() );
+}
+
+void ImfManager::Activate()
+{
+ Internal::Adaptor::ImfManager::GetImplementation(*this).Activate();
+}
+
+void ImfManager::Deactivate()
+{
+ Internal::Adaptor::ImfManager::GetImplementation(*this).Deactivate();
+}
+
+bool ImfManager::RestoreAfterFocusLost() const
+{
+ return Internal::Adaptor::ImfManager::GetImplementation(*this).RestoreAfterFocusLost();
+}
+
+void ImfManager::SetRestoreAferFocusLost( bool toggle )
+{
+ Internal::Adaptor::ImfManager::GetImplementation(*this).SetRestoreAferFocusLost( toggle );
+}
+
+void ImfManager::Reset()
+{
+ Internal::Adaptor::ImfManager::GetImplementation(*this).Reset();
+}
+
+void ImfManager::NotifyCursorPosition()
+{
+ Internal::Adaptor::ImfManager::GetImplementation(*this).NotifyCursorPosition();
+}
+
+void ImfManager::SetCursorPosition( unsigned int SetCursorPosition )
+{
+ Internal::Adaptor::ImfManager::GetImplementation(*this).SetCursorPosition( SetCursorPosition );
+}
+
+int ImfManager::GetCursorPosition()
+{
+ return Internal::Adaptor::ImfManager::GetImplementation(*this).GetCursorPosition();
+}
+
+void ImfManager::SetSurroundingText( std::string text )
+{
+ Internal::Adaptor::ImfManager::GetImplementation(*this).SetSurroundingText( text );
+}
+
+std::string ImfManager::GetSurroundingText()
+{
+ return Internal::Adaptor::ImfManager::GetImplementation(*this).GetSurroundingText();
+}
+
+ImfManager::ImfManagerSignalV2& ImfManager::ActivatedSignal()
+{
+ return Internal::Adaptor::ImfManager::GetImplementation(*this).ActivatedSignal();
+}
+
+ImfManager::ImfEventSignalV2& ImfManager::EventReceivedSignal()
+{
+ return Internal::Adaptor::ImfManager::GetImplementation(*this).EventReceivedSignal();
+}
+
+ImfManager::ImfManager(Internal::Adaptor::ImfManager *impl)
+ : BaseHandle(impl)
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "indicator-buffer.h"
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+IndicatorBuffer::IndicatorBuffer( Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pixelFormat )
+: mAdaptor(adaptor),
+ mImageWidth(width),
+ mImageHeight(height),
+ mPixelFormat(pixelFormat)
+{
+ DALI_ASSERT_ALWAYS( adaptor );
+
+ // Use BitmapImage when SharedGlBuffer extension is unavailable
+ mBitmapBuffer = new NativeBitmapBuffer( adaptor, mImageWidth, mImageHeight, mPixelFormat );
+ mNativeImage = mBitmapBuffer;
+}
+
+bool IndicatorBuffer::UpdatePixels( const unsigned char *src, size_t size )
+{
+ // Use double buffered bitmap when SharedGlBuffer extension is unavailable
+ mBitmapBuffer->Write( src, size );
+ return true;
+}
+
+NativeImage& IndicatorBuffer::GetNativeImage() const
+{
+ DALI_ASSERT_DEBUG(mNativeImage.Get());
+ return *mNativeImage;
+}
+
+void IndicatorBuffer::SetAdaptor( Adaptor* adaptor )
+{
+ mAdaptor = adaptor;
+}
+
+} // Adaptor
+} // Internal
+} // Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_INDICATOR_BUFFER_H__
+#define __DALI_INTERNAL_INDICATOR_BUFFER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/ref-object.h>
+
+// INTERNAL INCLUDES
+#include <native-bitmap-buffer-impl.h>
+#include <adaptor-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+namespace Adaptor
+{
+
+class NativeBitmapBuffer;
+class IndicatorBuffer;
+
+typedef IntrusivePtr<IndicatorBuffer> IndicatorBufferPtr;
+
+/**
+ * The IndicatorBuffer class uses the best available implementation for rendering indicator data.
+ * On platforms where EglImage is available it uses either SharedGlBuffer or PixmapImage, on older
+ * platforms it falls back to using a bitmap buffer based solution.
+ */
+class IndicatorBuffer : public RefObject
+{
+public:
+
+ /**
+ * Constructor
+ */
+ IndicatorBuffer( Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pixelFormat );
+
+ /**
+ * Copy bitmap data to pixel buffer.
+ * @param src bitmap data source
+ * @param size size of bitmap data
+ * @return true if successful, false otherwise
+ */
+ bool UpdatePixels( const unsigned char *src, size_t size );
+
+ /**
+ * Returns the NativeImage used internally
+ * @return the NativeImage used internally
+ */
+ NativeImage& GetNativeImage() const;
+
+ /**
+ * Set currently used Adaptor
+ * @param adaptor
+ */
+ void SetAdaptor( Adaptor* adaptor );
+
+private:
+ NativeImagePtr mNativeImage; ///< Image buffer created for shared file copy
+
+ NativeBitmapBufferPtr mBitmapBuffer; ///< Image buffer created for shared file copy if extension not available
+
+ Adaptor* mAdaptor;
+
+ int mImageWidth;
+ int mImageHeight;
+ Pixel::Format mPixelFormat;
+
+ // Only used with fallback bitmap buffer implementation
+ bool mUpdatingBitmap:1; ///< Whether BitmapImage is being uploaded to graphics memory
+ bool mUpdateBitmapAgain:1; ///< Whether to update BitmapImage again after upload complete
+};
+
+} // Adaptor
+} // Internal
+} // Dali
+
+#endif // __DALI_INTERNAL_INDICATOR_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "indicator-impl.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+#include <Evas.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include <dali/public-api/images/bitmap-image.h>
+#include <pixmap-image.h>
+#include <dali/public-api/actors/image-actor.h>
+#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/touch-point.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/actors/blending.h>
+#include <dali/public-api/shader-effects/shader-effect.h>
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <adaptor-impl.h>
+#include <accessibility-manager-impl.h>
+
+using Dali::Vector4;
+
+#if defined(DEBUG_ENABLED)
+#define STATE_DEBUG_STRING(state) (state==DISCONNECTED?"DISCONNECTED":state==CONNECTED?"CONNECTED":"UNKNOWN")
+#endif
+
+namespace
+{
+
+const float SLIDING_ANIMATION_DURATION( 0.2f ); // 200 milli seconds
+const float AUTO_INDICATOR_STAY_DURATION(3.0f); // 3 seconds
+const float SHOWING_DISTANCE_HEIGHT_RATE(0.34f); // 20 pixels
+
+enum
+{
+ KEEP_SHOWING = -1,
+ HIDE_NOW = 0
+};
+
+const int NUM_GRADIENT_INTERVALS(5); // Number of gradient intervals
+const Dali::Vector4 GRADIENT_COLORS[NUM_GRADIENT_INTERVALS+1] =
+{
+ Vector4(0.0f, 0.0f, 0.0f, 0.6f),
+ Vector4(0.0f, 0.0f, 0.0f, 0.38f),
+ Vector4(0.0f, 0.0f, 0.0f, 0.20f),
+ Vector4(0.0f, 0.0f, 0.0f, 0.08f),
+ Vector4(0.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 0.0f),
+};
+
+const float OPAQUE_THRESHOLD(0.99f);
+const float TRANSPARENT_THRESHOLD(0.05f);
+
+// Indicator orientation
+const char* ELM_INDICATOR_PORTRAIT("elm_indicator_portrait");
+const char* ELM_INDICATOR_LANDSCAPE("elm_indicator_landscape");
+const char* ELM_INDICATOR_PORTRAIT_FIXED_COLOR_STYLE("elm_indicator_portrait_fixed");
+const char* ELM_INDICATOR_LANDSCAPE_FIXED_COLOR_STYLE("elm_indicator_landscape_fixed");
+
+const char* MESH_VERTEX_SHADER =
+"attribute lowp vec3 aColor;\n"
+"varying mediump vec4 vColor;\n"
+"void main()\n"
+"{\n"
+" gl_Position = uMvpMatrix * vec4(aPosition, 1.0);\n"
+" vColor = vec4(aColor.r, aColor.g, aColor.b, aTexCoord.x);\n"
+"}\n";
+
+const char* MESH_FRAGMENT_SHADER =
+"varying mediump vec4 vColor;\n"
+"void main()\n"
+"{\n"
+" gl_FragColor = vColor*uColor;\n"
+"}\n";
+
+// Copied from elm_win.h
+
+/**
+ * Defines the type modes of indicator that can be shown
+ * If the indicator can support several type of indicator,
+ * you can use this enum value to deal with different type of indicator
+ */
+typedef enum
+{
+ ELM_WIN_INDICATOR_TYPE_UNKNOWN, /**< Unknown indicator type mode */
+ ELM_WIN_INDICATOR_TYPE_1, /**< Type 0 the the indicator */
+ ELM_WIN_INDICATOR_TYPE_2, /**< Type 1 the indicator */
+} Elm_Win_Indicator_Type_Mode;
+
+// Copied from ecore_evas_extn.c
+
+enum // opcodes
+{
+ OP_RESIZE,
+ OP_SHOW,
+ OP_HIDE,
+ OP_FOCUS,
+ OP_UNFOCUS,
+ OP_UPDATE,
+ OP_UPDATE_DONE,
+ OP_LOCK_FILE,
+ OP_SHM_REF,
+ OP_EV_MOUSE_IN,
+ OP_EV_MOUSE_OUT,
+ OP_EV_MOUSE_UP,
+ OP_EV_MOUSE_DOWN,
+ OP_EV_MOUSE_MOVE,
+ OP_EV_MOUSE_WHEEL,
+ OP_EV_MULTI_UP,
+ OP_EV_MULTI_DOWN,
+ OP_EV_MULTI_MOVE,
+ OP_EV_KEY_UP,
+ OP_EV_KEY_DOWN,
+ OP_EV_HOLD,
+ OP_MSG_PARENT,
+ OP_MSG,
+ OP_PIXMAP_REF
+};
+
+// Copied from elm_conform.c
+
+const int MSG_DOMAIN_CONTROL_INDICATOR(0x10001);
+const int MSG_ID_INDICATOR_REPEAT_EVENT(0x10002);
+const int MSG_ID_INDICATOR_ROTATION(0x10003);
+const int MSG_ID_INDICATOR_OPACITY(0X1004);
+const int MSG_ID_INDICATOR_TYPE(0X1005);
+const int MSG_ID_INDICATOR_START_ANIMATION(0X10006);
+
+struct IpcDataUpdate
+{
+ int x, w, y, h;
+};
+
+struct IpcDataResize
+{
+ int w, h;
+};
+
+struct IpcIndicatorDataAnimation
+{
+ unsigned int xwin;
+ double duration;
+};
+
+struct IpcDataEvMouseUp
+{
+ int b;
+ Evas_Button_Flags flags;
+ int mask;
+ unsigned int timestamp;
+ Evas_Event_Flags event_flags;
+
+ IpcDataEvMouseUp(unsigned long timestamp)
+ : b(1),
+ flags(EVAS_BUTTON_NONE),
+ mask(0),
+ timestamp(static_cast<unsigned int>(timestamp)),
+ event_flags(EVAS_EVENT_FLAG_NONE)
+ {
+ }
+};
+
+struct IpcDataEvMouseDown
+{
+ int b;
+ Evas_Button_Flags flags;
+ int mask;
+ unsigned int timestamp;
+ Evas_Event_Flags event_flags;
+
+ IpcDataEvMouseDown(unsigned long timestamp)
+ : b(1),
+ flags(EVAS_BUTTON_NONE),
+ mask(0),
+ timestamp(static_cast<unsigned int>(timestamp)),
+ event_flags(EVAS_EVENT_FLAG_NONE)
+ {
+ }
+};
+
+struct IpcDataEvMouseMove
+{
+ int x, y;
+ Evas_Button_Flags flags;
+ int mask;
+ unsigned int timestamp;
+ Evas_Event_Flags event_flags;
+
+ IpcDataEvMouseMove(const Dali::TouchPoint& touchPoint, unsigned long timestamp)
+ : x(static_cast<Evas_Coord>(touchPoint.local.x)),
+ y(static_cast<Evas_Coord>(touchPoint.local.y)),
+ flags(EVAS_BUTTON_NONE),
+ mask(0),
+ timestamp(static_cast<unsigned int>(timestamp)),
+ event_flags(EVAS_EVENT_FLAG_NONE)
+ {
+ }
+};
+
+struct IpcDataEvMouseOut
+{
+ unsigned int timestamp;
+ int mask;
+ Evas_Event_Flags event_flags;
+
+ IpcDataEvMouseOut(unsigned long timestamp)
+ : timestamp(static_cast<unsigned int>(timestamp)),
+ mask(0),
+ event_flags(EVAS_EVENT_FLAG_NONE)
+ {
+ }
+};
+
+void SetMeshDataColors(Dali::AnimatableMesh mesh, const Vector4 (&colors)[NUM_GRADIENT_INTERVALS+1])
+{
+ for( size_t i=0; i<NUM_GRADIENT_INTERVALS+1; i++ )
+ {
+ int j=i*2;
+ mesh[j].SetColor(colors[i]);
+ mesh[j+1].SetColor(colors[i]);
+ mesh[j].SetTextureCoords(Dali::Vector2(colors[i].a, colors[i].a));
+ mesh[j+1].SetTextureCoords(Dali::Vector2(colors[i].a, colors[i].a));
+ }
+}
+
+void SetMeshDataColors(Dali::AnimatableMesh mesh, const Vector4& color)
+{
+ for( size_t i=0, length=NUM_GRADIENT_INTERVALS+1 ; i<length; i++ )
+ {
+ int j=i*2;
+ mesh[j].SetColor(color);
+ mesh[j+1].SetColor(color);
+ mesh[j].SetTextureCoords(Dali::Vector2(color.a, color.a));
+ mesh[j+1].SetTextureCoords(Dali::Vector2(color.a, color.a));
+ }
+}
+
+} // anonymous namespace
+
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gIndicatorLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_INDICATOR");
+#endif
+
+
+Indicator::LockFile::LockFile(const char* filename)
+: mFilename(filename),
+ mErrorThrown(false)
+{
+ mFileDescriptor = open(filename, O_RDWR);
+ if( mFileDescriptor == -1 )
+ {
+ mFileDescriptor = 0;
+ mErrorThrown = true;
+ DALI_LOG_ERROR( "### Cannot open %s for indicator lock ###\n", mFilename.c_str() );
+ }
+}
+
+Indicator::LockFile::~LockFile()
+{
+ // Closing file descriptor also unlocks file.
+ close( mFileDescriptor );
+}
+
+bool Indicator::LockFile::Lock()
+{
+ DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
+
+ bool locked = false;
+ if( mFileDescriptor > 0 )
+ {
+ if( lockf( mFileDescriptor, F_LOCK, 0 ) == 0 ) // Note, operation may block.
+ {
+ locked = true;
+ }
+ else
+ {
+ if( errno == EBADF )
+ {
+ // file descriptor is no longer valid or not writable
+ mFileDescriptor = 0;
+ mErrorThrown = true;
+ DALI_LOG_ERROR( "### Cannot lock indicator: bad file descriptor for %s ###\n", mFilename.c_str() );
+ }
+ }
+ }
+
+ return locked;
+}
+
+void Indicator::LockFile::Unlock()
+{
+ DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
+ if( lockf( mFileDescriptor, F_ULOCK, 0 ) != 0 )
+ {
+ if( errno == EBADF )
+ {
+ // file descriptor is no longer valid or not writable
+ mFileDescriptor = 0;
+ mErrorThrown = true;
+ DALI_LOG_ERROR( "### Cannot unlock indicator: bad file descriptor for %s\n", mFilename.c_str() );
+ }
+ }
+}
+
+bool Indicator::LockFile::RetrieveAndClearErrorStatus()
+{
+ bool error = mErrorThrown;
+ mErrorThrown = false;
+ return error;
+}
+
+Indicator::ScopedLock::ScopedLock(LockFile* lockFile)
+: mLockFile(lockFile),
+ mLocked(false)
+{
+ if(mLockFile)
+ {
+ mLocked = mLockFile->Lock();
+ }
+}
+
+Indicator::ScopedLock::~ScopedLock()
+{
+ if( mLockFile )
+ {
+ mLockFile->Unlock();
+ }
+}
+
+bool Indicator::ScopedLock::IsLocked()
+{
+ return mLocked;
+}
+
+Indicator::Indicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientation, Dali::Window::IndicatorStyle style, Observer* observer )
+: mPixmap( 0 ),
+ mGestureDetected( false ),
+ mConnection( this ),
+ mStyle( style ),
+ mOpacityMode( Dali::Window::OPAQUE ),
+ mState( DISCONNECTED ),
+ mAdaptor(adaptor),
+ mServerConnection( NULL ),
+ mLock( NULL ),
+ mSharedFile( NULL ),
+ mObserver( observer ),
+ mOrientation( orientation ),
+ mRotation( 0 ),
+ mImageWidth( 0 ),
+ mImageHeight( 0 ),
+ mVisible( Dali::Window::VISIBLE ),
+ mIsShowing( true ),
+ mIsAnimationPlaying( false )
+{
+ mIndicatorImageActor = Dali::ImageActor::New();
+ mIndicatorImageActor.SetBlendFunc( Dali::BlendingFactor::ONE, Dali::BlendingFactor::ONE_MINUS_SRC_ALPHA,
+ Dali::BlendingFactor::ONE, Dali::BlendingFactor::ONE );
+
+ mIndicatorImageActor.SetParentOrigin( ParentOrigin::TOP_CENTER );
+ mIndicatorImageActor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+
+ // Indicator image handles the touch event including "leave"
+ mIndicatorImageActor.SetLeaveRequired( true );
+ mIndicatorImageActor.TouchedSignal().Connect( this, &Indicator::OnTouched );
+
+ SetBackground();
+ mBackgroundActor.SetParentOrigin( ParentOrigin::TOP_CENTER );
+ mBackgroundActor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ mBackgroundActor.SetZ( -0.02f );
+
+ // add background to image actor to move it with indicator image
+ mIndicatorImageActor.Add( mBackgroundActor );
+
+ mIndicatorActor = Dali::Actor::New();
+ mIndicatorActor.Add( mIndicatorImageActor );
+
+ if( mOrientation == Dali::Window::LANDSCAPE || mOrientation == Dali::Window::LANDSCAPE_INVERSE )
+ {
+ mBackgroundActor.SetVisible( false );
+ }
+
+ // Event handler to find out flick down gesture
+ mEventActor = Dali::Actor::New();
+ mEventActor.SetParentOrigin( ParentOrigin::TOP_CENTER );
+ mEventActor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ mEventActor.SetZ( -0.01f );
+ mIndicatorActor.Add( mEventActor );
+
+ // Attach pan gesture to find flick down during hiding.
+ // It can prevent the problem that scrollview gets pan gesture even indicator area is touched,
+ // since it consumes the pan gesture in advance.
+ mPanDetector = Dali::PanGestureDetector::New();
+ mPanDetector.DetectedSignal().Connect( this, &Indicator::OnPan );
+ mPanDetector.Attach( mEventActor );
+
+ Open( orientation );
+
+ // register indicator to accessibility manager
+ Dali::AccessibilityManager accessibilityManager = AccessibilityManager::Get();
+ if(accessibilityManager)
+ {
+ AccessibilityManager::GetImplementation( accessibilityManager ).SetIndicator( this );
+ }
+}
+
+Indicator::~Indicator()
+{
+ if(mEventActor)
+ {
+ mEventActor.TouchedSignal().Disconnect( this, &Indicator::OnTouched );
+ }
+ Disconnect();
+}
+
+void Indicator::SetAdaptor(Adaptor* adaptor)
+{
+ mAdaptor = adaptor;
+ mIndicatorBuffer->SetAdaptor( adaptor );
+}
+
+Dali::Actor Indicator::GetActor()
+{
+ return mIndicatorActor;
+}
+
+void Indicator::Open( Dali::Window::WindowOrientation orientation )
+{
+ DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
+
+ // Calls from Window should be set up to ensure we are in a
+ // disconnected state before opening a second time.
+ DALI_ASSERT_DEBUG( mState == DISCONNECTED );
+
+ Connect( orientation );
+
+ // Change background visibility depending on orientation
+ if(mOrientation == Dali::Window::PORTRAIT || mOrientation == Dali::Window::PORTRAIT_INVERSE)
+ {
+ mBackgroundActor.SetVisible(true);
+ }
+ else
+ {
+ mBackgroundActor.SetVisible(false);
+ }
+}
+
+void Indicator::Close()
+{
+ DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "State: %s\n", STATE_DEBUG_STRING(mState) );
+
+ if( mState == CONNECTED )
+ {
+ Disconnect();
+ if( mObserver != NULL )
+ {
+ mObserver->IndicatorClosed( this );
+ }
+ }
+
+ Dali::Image emptyImage;
+ mIndicatorImageActor.SetImage(emptyImage);
+}
+
+void Indicator::SetOpacityMode( Dali::Window::IndicatorBgOpacity mode )
+{
+ mOpacityMode = mode;
+ SetBackground();
+}
+
+void Indicator::SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool forceUpdate )
+{
+ if ( visibleMode != mVisible || forceUpdate )
+ {
+ // If we were previously hidden, then we should update the image data before we display the indicator
+ if ( mVisible == Dali::Window::INVISIBLE )
+ {
+ UpdateImageData();
+ }
+
+ mVisible = visibleMode;
+
+ if( mIndicatorImageActor.GetImage() )
+ {
+ if( CheckVisibleState() && mVisible == Dali::Window::AUTO )
+ {
+ // hide indicator
+ ShowIndicator( AUTO_INDICATOR_STAY_DURATION /* stay n sec */ );
+ }
+ else if( CheckVisibleState() && mVisible == Dali::Window::VISIBLE )
+ {
+ // show indicator
+ ShowIndicator( KEEP_SHOWING );
+ }
+ else
+ {
+ // hide indicator
+ ShowIndicator( HIDE_NOW );
+ }
+ }
+ }
+}
+
+bool Indicator::IsConnected()
+{
+ return ( mState == CONNECTED );
+}
+
+bool Indicator::SendMessage( int messageDomain, int messageId, const void *data, int size )
+{
+ if(IsConnected())
+ {
+ return mServerConnection->SendEvent( OP_MSG, messageDomain, messageId, data, size );
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool Indicator::OnTouched(Dali::Actor indicator, const Dali::TouchEvent& touchEvent)
+{
+ if( mServerConnection )
+ {
+ const TouchPoint& touchPoint = touchEvent.GetPoint( 0 );
+
+ // Send touch event to indicator server when indicator is showing
+ if( CheckVisibleState() || mIsShowing )
+ {
+ switch( touchPoint.state )
+ {
+ case Dali::TouchPoint::Down:
+ {
+ IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time );
+ IpcDataEvMouseDown ipcDown( touchEvent.time );
+ mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) );
+ mServerConnection->SendEvent( OP_EV_MOUSE_DOWN, &ipcDown, sizeof(ipcDown) );
+
+ if( mVisible == Dali::Window::AUTO )
+ {
+ // Stop hiding indicator
+ ShowIndicator( KEEP_SHOWING );
+ }
+ }
+ break;
+
+ case Dali::TouchPoint::Motion:
+ {
+ IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time );
+ mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) );
+ }
+ break;
+
+ case Dali::TouchPoint::Up:
+ {
+ IpcDataEvMouseUp ipcUp( touchEvent.time );
+ mServerConnection->SendEvent( OP_EV_MOUSE_UP, &ipcUp, sizeof(ipcUp) );
+
+ if( mVisible == Dali::Window::AUTO )
+ {
+ // Hide indicator
+ ShowIndicator( 0.5f /* hide after 0.5 sec */ );
+ }
+ }
+ break;
+
+ case Dali::TouchPoint::Leave:
+ {
+ IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time );
+ mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) );
+ IpcDataEvMouseUp ipcOut( touchEvent.time );
+ mServerConnection->SendEvent( OP_EV_MOUSE_OUT, &ipcOut, sizeof(ipcOut) );
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Return the current orientation in degrees
+ * @return value of 0, 90, 180 or 270
+ */
+int Indicator::OrientationToDegrees( Dali::Window::WindowOrientation orientation )
+{
+ int degree = 0;
+
+ switch( orientation )
+ {
+ case Dali::Window::PORTRAIT:
+ degree = 0;
+ break;
+ case Dali::Window::PORTRAIT_INVERSE:
+ degree = 180;
+ break;
+ case Dali::Window::LANDSCAPE:
+ degree = 90;
+ break;
+ case Dali::Window::LANDSCAPE_INVERSE:
+ degree = 270;
+ break;
+ }
+ return degree;
+}
+
+bool Indicator::Connect( Dali::Window::WindowOrientation orientation )
+{
+ DALI_ASSERT_DEBUG( mState == DISCONNECTED );
+
+ bool connected = false;
+ mOrientation = orientation;
+ mRotation = OrientationToDegrees(mOrientation);
+
+ switch( orientation )
+ {
+ case Dali::Window::PORTRAIT:
+ if(mStyle == Dali::Window::FIXED_COLOR)
+ {
+ connected = Connect( ELM_INDICATOR_PORTRAIT_FIXED_COLOR_STYLE );
+ }
+ else
+ {
+ connected = Connect( ELM_INDICATOR_PORTRAIT );
+ }
+ break;
+ case Dali::Window::PORTRAIT_INVERSE:
+ if(mStyle == Dali::Window::FIXED_COLOR)
+ {
+ connected = Connect( ELM_INDICATOR_PORTRAIT_FIXED_COLOR_STYLE );
+ }
+ else
+ {
+ connected = Connect( ELM_INDICATOR_PORTRAIT );
+ }
+ break;
+ case Dali::Window::LANDSCAPE:
+ if(mStyle == Dali::Window::FIXED_COLOR)
+ {
+ connected = Connect( ELM_INDICATOR_LANDSCAPE_FIXED_COLOR_STYLE );
+ }
+ else
+ {
+ connected = Connect( ELM_INDICATOR_LANDSCAPE );
+ }
+ break;
+ case Dali::Window::LANDSCAPE_INVERSE:
+ if(mStyle == Dali::Window::FIXED_COLOR)
+ {
+ connected = Connect( ELM_INDICATOR_LANDSCAPE_FIXED_COLOR_STYLE );
+ }
+ else
+ {
+ connected = Connect( ELM_INDICATOR_LANDSCAPE );
+ }
+ break;
+ }
+
+ return connected;
+}
+
+bool Indicator::Connect( const char *serviceName )
+{
+ DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
+
+ bool connected = false;
+
+ mServerConnection = new ServerConnection( serviceName, 0, false, this );
+ if( mServerConnection )
+ {
+ connected = mServerConnection->IsConnected();
+ if( ! connected )
+ {
+ delete mServerConnection;
+ mServerConnection = NULL;
+ }
+ }
+
+ if( !connected )
+ {
+ StartReconnectionTimer();
+ }
+ else
+ {
+ mState = CONNECTED;
+ }
+
+ return connected;
+}
+
+void Indicator::StartReconnectionTimer()
+{
+ if( ! mReconnectTimer )
+ {
+ mReconnectTimer = Dali::Timer::New(1000);
+ mConnection.DisconnectAll();
+ mReconnectTimer.TickSignal().Connect( mConnection, &Indicator::OnReconnectTimer );
+ }
+ mReconnectTimer.Start();
+}
+
+bool Indicator::OnReconnectTimer()
+{
+ bool retry = false;
+
+ if( mState == DISCONNECTED )
+ {
+ if( ! Connect( mOrientation ) )
+ {
+ retry = true;
+ }
+ }
+
+ return retry;
+}
+
+void Indicator::Disconnect()
+{
+ DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
+
+ mState = DISCONNECTED;
+
+ delete mLock;
+ mLock = NULL;
+
+ delete mSharedFile;
+ mSharedFile = NULL;
+
+ delete mServerConnection;
+ mServerConnection = NULL;
+}
+
+void Indicator::NewLockFile( Ecore_Ipc_Event_Server_Data *epcEvent )
+{
+ DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
+
+ delete mLock;
+ mLock = NULL;
+
+ if ( (epcEvent->data) &&
+ (epcEvent->size > 0) &&
+ (((unsigned char *)epcEvent->data)[epcEvent->size - 1] == 0) )
+ {
+ const char* lockFile = static_cast< const char* >( epcEvent->data );
+ mLock = new Indicator::LockFile( lockFile );
+ if( mLock->RetrieveAndClearErrorStatus() )
+ {
+ DALI_LOG_ERROR( "### Indicator error: Cannot open lock file %s ###\n", lockFile );
+ }
+ }
+}
+
+void Indicator::Resize( int width, int height )
+{
+ if( width < 1 )
+ {
+ width = 1;
+ }
+ if( height < 1 )
+ {
+ height = 1;
+ }
+
+ if( mImageWidth != width || mImageHeight != height )
+ {
+ mImageWidth = width;
+ mImageHeight = height;
+
+ // We don't currently handle the pixel buffer size being changed. Create a new image instead
+ if( mSharedFile )
+ {
+ CreateNewImage();
+ }
+ }
+}
+
+void Indicator::LoadPixmapImage( Ecore_Ipc_Event_Server_Data *epcEvent )
+{
+ DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
+
+ // epcEvent->ref == w
+ // epcEvent->ref_to == h
+ // epcEvent->response == alpha
+ // epcEvent->data = pixmap id
+ if( ( epcEvent->data ) &&
+ (epcEvent->size >= (int)sizeof(PixmapId)) )
+ {
+ if( mSharedFile != NULL )
+ {
+ delete mSharedFile;
+ mSharedFile = NULL;
+ }
+
+ if( (epcEvent->ref > 0) && (epcEvent->ref_to > 0) )
+ {
+ mImageWidth = epcEvent->ref;
+ mImageHeight = epcEvent->ref_to;
+
+ mPixmap = *(static_cast<PixmapId*>(epcEvent->data));
+ CreateNewPixmapImage();
+
+ if( CheckVisibleState() )
+ {
+ // set default indicator type (enable the quick panel)
+ OnIndicatorTypeChanged( INDICATOR_TYPE_1 );
+ }
+ else
+ {
+ // set default indicator type (disable the quick panel)
+ OnIndicatorTypeChanged( INDICATOR_TYPE_2 );
+ }
+
+ SetVisible(mVisible, true);
+ }
+ }
+}
+
+void Indicator::LoadSharedImage( Ecore_Ipc_Event_Server_Data *epcEvent )
+{
+ DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
+
+ // epcEvent->ref == w
+ // epcEvent->ref_to == h
+ // epcEvent->response == alpha
+ // epcEvent->data = shm ref string + nul byte
+ if( ( epcEvent->data ) &&
+ ( ( unsigned char * ) epcEvent->data)[ epcEvent->size - 1 ] == 0 )
+ {
+ if( mSharedFile != NULL )
+ {
+ delete mSharedFile;
+ mSharedFile = NULL;
+ }
+
+ if( (epcEvent->ref > 0) && (epcEvent->ref_to > 0) )
+ {
+ mImageWidth = epcEvent->ref;
+ mImageHeight = epcEvent->ref_to;
+
+ char* sharedFilename = static_cast<char*>(epcEvent->data);
+
+ mSharedFile = SharedFile::New( sharedFilename, mImageWidth * mImageWidth * 4, true );
+ if( mSharedFile != NULL )
+ {
+ CreateNewImage();
+ mEventActor.SetSize(mImageWidth, mImageHeight);
+
+ if( CheckVisibleState() )
+ {
+ // set default indicator type (enable the quick panel)
+ OnIndicatorTypeChanged( INDICATOR_TYPE_1 );
+ }
+ else
+ {
+ // set default indicator type (disable the quick panel)
+ OnIndicatorTypeChanged( INDICATOR_TYPE_2 );
+ }
+
+ SetVisible(mVisible, true);
+ }
+ }
+ }
+}
+
+void Indicator::UpdateImageData()
+{
+ DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "State: %s mVisible: %s\n", STATE_DEBUG_STRING(mState), mVisible?"T":"F" );
+
+ if( mState == CONNECTED && mVisible )
+ {
+ if(mPixmap == 0)
+ {
+ // in case of shm indicator (not pixmap), not sure we can skip it when mIsShowing is false
+ CopyToBuffer();
+ }
+ else
+ {
+ if(mIsShowing)
+ {
+ mAdaptor->RequestUpdateOnce();
+ }
+ }
+ }
+}
+
+bool Indicator::CopyToBuffer()
+{
+ bool success = false;
+
+ if( mLock )
+ {
+ Indicator::ScopedLock scopedLock(mLock);
+ if( mLock->RetrieveAndClearErrorStatus() )
+ {
+ // Do nothing here.
+ }
+ else if( scopedLock.IsLocked() )
+ {
+ unsigned char *src = mSharedFile->GetAddress();
+ size_t size = mImageWidth * mImageHeight * 4;
+
+ if( mIndicatorBuffer->UpdatePixels( src, size ) )
+ {
+ mAdaptor->RequestUpdateOnce();
+ success = true;
+ }
+ }
+ }
+
+ return success;
+}
+
+void Indicator::SetBackground()
+{
+ if( ! mBackgroundActor )
+ {
+ ConstructBackgroundMesh();
+ }
+
+ switch( mOpacityMode )
+ {
+ case Dali::Window::TRANSLUCENT:
+ {
+ SetMeshDataColors( mBackgroundMesh, GRADIENT_COLORS );
+ }
+ break;
+
+ case Dali::Window::TRANSPARENT:
+ {
+ SetMeshDataColors( mBackgroundMesh, Color::TRANSPARENT );
+ }
+ break;
+
+ case Dali::Window::OPAQUE:
+ default :
+ {
+ SetMeshDataColors( mBackgroundMesh, Color::BLACK );
+ }
+ break;
+ }
+}
+
+void Indicator::CreateNewPixmapImage()
+{
+ DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "W:%d H:%d\n", mImageWidth, mImageHeight );
+ Dali::PixmapImagePtr pixmapImage = Dali::PixmapImage::New(mPixmap, Dali::Adaptor::Get());
+
+ if( pixmapImage )
+ {
+ mIndicatorImageActor.SetImage( Dali::Image::New(*pixmapImage) );
+ mIndicatorImageActor.SetSize( mImageWidth, mImageHeight );
+ mIndicatorActor.SetSize( mImageWidth, mImageHeight );
+ mEventActor.SetSize(mImageWidth, mImageHeight);
+
+ SetBackground();
+ if( mBackgroundActor )
+ {
+ mBackgroundActor.SetSize( mImageWidth, mImageHeight );
+ }
+ }
+ else
+ {
+ DALI_LOG_WARNING("### Cannot create indicator image - disconnecting ###\n");
+ Disconnect();
+ if( mObserver != NULL )
+ {
+ mObserver->IndicatorClosed( this );
+ }
+ // Don't do connection in this callback - strange things happen!
+ StartReconnectionTimer();
+ }
+}
+
+void Indicator::CreateNewImage()
+{
+ DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "W:%d H:%d\n", mImageWidth, mImageHeight );
+ mIndicatorBuffer = new IndicatorBuffer( mAdaptor, mImageWidth, mImageHeight, Pixel::BGRA8888 );
+ Dali::Image image = Dali::Image::New( mIndicatorBuffer->GetNativeImage() );
+
+ if( CopyToBuffer() ) // Only create images if we have valid image buffer
+ {
+ mIndicatorImageActor.SetImage( image );
+ mIndicatorImageActor.SetSize( mImageWidth, mImageHeight );
+ mIndicatorActor.SetSize( mImageWidth, mImageHeight );
+ mEventActor.SetSize(mImageWidth, mImageHeight);
+
+ SetBackground();
+ if( mBackgroundActor )
+ {
+ mBackgroundActor.SetSize( mImageWidth, mImageHeight );
+ }
+ }
+ else
+ {
+ DALI_LOG_WARNING("### Cannot create indicator image - disconnecting ###\n");
+ Disconnect();
+ if( mObserver != NULL )
+ {
+ mObserver->IndicatorClosed( this );
+ }
+ // Don't do connection in this callback - strange things happen!
+ StartReconnectionTimer();
+ }
+}
+
+void Indicator::OnIndicatorTypeChanged( Type indicatorType )
+{
+ if( mObserver != NULL )
+ {
+ mObserver->IndicatorTypeChanged( indicatorType );
+ }
+}
+
+void Indicator::DataReceived( void* event )
+{
+ DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
+ Ecore_Ipc_Event_Server_Data *epcEvent = static_cast<Ecore_Ipc_Event_Server_Data *>( event );
+
+ switch( epcEvent->minor )
+ {
+ case OP_UPDATE:
+ DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_UPDATE\n" );
+ if(mPixmap != 0 && mIsShowing)
+ {
+ mAdaptor->RequestUpdateOnce();
+ }
+ break;
+
+ case OP_UPDATE_DONE:
+ DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_UPDATE_DONE\n" );
+ UpdateImageData();
+ break;
+
+ case OP_LOCK_FILE:
+ DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_LOCK_FILE\n" );
+ NewLockFile( epcEvent );
+ break;
+
+ case OP_SHM_REF:
+ DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_SHM_REF\n" );
+ LoadSharedImage( epcEvent );
+ break;
+
+ case OP_PIXMAP_REF:
+ DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_PIXMAP_REF\n" );
+ LoadPixmapImage( epcEvent );
+ break;
+
+ case OP_RESIZE:
+ DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_RESIZE\n" );
+
+ if( (epcEvent->data) && (epcEvent->size >= (int)sizeof(IpcDataResize)) )
+ {
+ IpcDataResize *newSize = static_cast<IpcDataResize*>( epcEvent->data );
+ Resize( newSize->w, newSize->h );
+ }
+ break;
+
+ case OP_MSG_PARENT:
+ {
+ int msgDomain = epcEvent->ref;
+ int msgId = epcEvent->ref_to;
+
+ void *msgData = NULL;
+ int msgDataSize = 0;
+ msgData = epcEvent->data;
+ msgDataSize = epcEvent->size;
+
+ if( msgDomain == MSG_DOMAIN_CONTROL_INDICATOR )
+ {
+ switch( msgId )
+ {
+ case MSG_ID_INDICATOR_TYPE:
+ {
+ DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_MSG_PARENT, INDICATOR_TYPE\n" );
+ Type* indicatorType = static_cast<Type*>( epcEvent->data );
+ OnIndicatorTypeChanged( *indicatorType );
+ break;
+ }
+
+ case MSG_ID_INDICATOR_START_ANIMATION:
+ {
+ if (msgDataSize != (int)sizeof(IpcIndicatorDataAnimation))
+ {
+ DALI_LOG_ERROR("Message data is incorrect");
+ break;
+ }
+
+ IpcIndicatorDataAnimation *animData = static_cast<IpcIndicatorDataAnimation*>(msgData);
+
+ if(!CheckVisibleState())
+ {
+ ShowIndicator( animData->duration /* n sec */ );
+ }
+ break;
+ }
+
+ }
+ }
+ break;
+ }
+ }
+}
+
+void Indicator::ConnectionClosed()
+{
+ DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
+
+ // Will get this callback if the server connection failed to start up.
+ delete mServerConnection;
+ mServerConnection = NULL;
+ mState = DISCONNECTED;
+
+ // Attempt to re-connect
+ Connect(mOrientation);
+}
+
+bool Indicator::CheckVisibleState()
+{
+ if( mOrientation == Dali::Window::LANDSCAPE
+ || mOrientation == Dali::Window::LANDSCAPE_INVERSE
+ || (mVisible != Dali::Window::VISIBLE) )
+ {
+ return false;
+ }
+
+ return true;
+}
+
+void Indicator::ConstructBackgroundMesh()
+{
+ // Construct 5 interval mesh
+ // 0 +---+ 1
+ // | \ |
+ // 2 +---+ 3
+ // | \ |
+ // 4 +---+ 5
+ // | \ |
+ // 6 +---+ 7
+ // | \ |
+ // 8 +---+ 9
+ // | \ |
+ // 10 +---+ 11
+ Dali::AnimatableMesh::Faces faces;
+ faces.reserve(NUM_GRADIENT_INTERVALS * 6); // 2 tris per interval
+ for(int i=0; i<NUM_GRADIENT_INTERVALS; i++)
+ {
+ int j=i*2;
+ faces.push_back(j); faces.push_back(j+3); faces.push_back(j+1);
+ faces.push_back(j); faces.push_back(j+2); faces.push_back(j+3);
+ }
+
+ mBackgroundMesh = Dali::AnimatableMesh::New((NUM_GRADIENT_INTERVALS+1)*2, faces);
+ float interval=1.0f / (float)NUM_GRADIENT_INTERVALS;
+ for(int i=0;i<NUM_GRADIENT_INTERVALS+1;i++)
+ {
+ int j=i*2;
+ mBackgroundMesh[j ].SetPosition(Vector3(-0.5f, -0.5f+(interval*(float)i), 0.0f));
+ mBackgroundMesh[j+1].SetPosition(Vector3( 0.5f, -0.5f+(interval*(float)i), 0.0f));
+ }
+
+ mBackgroundActor = Dali::MeshActor::New(mBackgroundMesh);
+ mBackgroundActor.SetAffectedByLighting(false);
+ Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( MESH_VERTEX_SHADER, MESH_FRAGMENT_SHADER,
+ GEOMETRY_TYPE_MESH, // Using vertex color
+ Dali::ShaderEffect::HINT_BLENDING );
+ mBackgroundActor.SetShaderEffect(shaderEffect);
+}
+
+/**
+ * duration can be this
+ *
+ * enum
+ * {
+ * KEEP_SHOWING = -1,
+ * HIDE_NOW = 0
+ * };
+ */
+void Indicator::ShowIndicator(float duration)
+{
+ if( !mIndicatorAnimation )
+ {
+ mIndicatorAnimation = Dali::Animation::New(SLIDING_ANIMATION_DURATION);
+ mIndicatorAnimation.FinishedSignal().Connect(this, &Indicator::OnAnimationFinished);
+ }
+
+ if(mIsShowing && duration != 0)
+ {
+ // If need to show during showing, do nothing.
+ // In 2nd phase (below) will update timer
+ }
+ else if(!mIsShowing && mIsAnimationPlaying && duration == 0)
+ {
+ // If need to hide during hiding or hidden already, do nothing
+ }
+ else
+ {
+ if(duration == 0)
+ {
+ mIndicatorAnimation.MoveTo(mIndicatorImageActor, Vector3(0, -mImageHeight, 0), Dali::AlphaFunctions::EaseOut);
+
+ mIsShowing = false;
+
+ OnIndicatorTypeChanged( INDICATOR_TYPE_2 ); // un-toucable
+ }
+ else
+ {
+ mIndicatorAnimation.MoveTo(mIndicatorImageActor, Vector3(0, 0, 0), Dali::AlphaFunctions::EaseOut);
+
+ mIsShowing = true;
+
+ OnIndicatorTypeChanged( INDICATOR_TYPE_1 ); // touchable
+ }
+
+ mIndicatorAnimation.Play();
+ mIsAnimationPlaying = true;
+ }
+
+ if(duration > 0)
+ {
+ if(!mShowTimer)
+ {
+ mShowTimer = Dali::Timer::New(1000 * duration);
+ mShowTimer.TickSignal().Connect(this, &Indicator::OnShowTimer);
+ }
+ mShowTimer.SetInterval(1000* duration);
+ mShowTimer.Start();
+
+ if( mVisible == Dali::Window::AUTO )
+ {
+ // check the stage touch
+ Dali::Stage::GetCurrent().TouchedSignal().Connect( this, &Indicator::OnStageTouched );
+ }
+ }
+ else
+ {
+ if(mShowTimer && mShowTimer.IsRunning())
+ {
+ mShowTimer.Stop();
+ }
+
+ if( mVisible == Dali::Window::AUTO )
+ {
+ // check the stage touch
+ Dali::Stage::GetCurrent().TouchedSignal().Disconnect( this, &Indicator::OnStageTouched );
+ }
+ }
+}
+
+bool Indicator::OnShowTimer()
+{
+ // after time up, hide indicator
+ ShowIndicator( HIDE_NOW );
+
+ return false;
+}
+
+void Indicator::OnAnimationFinished(Dali::Animation& animation)
+{
+ mIsAnimationPlaying = false;
+}
+
+void Indicator::OnPan( Dali::Actor actor, Dali::PanGesture gesture )
+{
+ if( mServerConnection )
+ {
+ switch( gesture.state )
+ {
+ case Gesture::Started:
+ {
+ mGestureDetected = false;
+
+ // The gesture position is the current position after it has moved by the displacement.
+ // We want to reference the original position.
+ mGestureDeltaY = gesture.position.y - gesture.displacement.y;
+ }
+
+ // No break, Fall through
+ case Gesture::Continuing:
+ {
+ if( mVisible == Dali::Window::AUTO && !mIsShowing )
+ {
+ // Only take one touch point
+ if( gesture.numberOfTouches == 1 && mGestureDetected == false )
+ {
+ mGestureDeltaY += gesture.displacement.y;
+
+ if( mGestureDeltaY >= mImageHeight * SHOWING_DISTANCE_HEIGHT_RATE )
+ {
+ ShowIndicator( AUTO_INDICATOR_STAY_DURATION );
+ mGestureDetected = true;
+ }
+ }
+ }
+
+ break;
+ }
+
+ case Gesture::Finished:
+ case Gesture::Cancelled:
+ {
+ // if indicator is showing, hide again when touching is finished (Since touch leave is activated, checking it in gesture::finish instead of touch::up)
+ if( mVisible == Dali::Window::AUTO && mIsShowing )
+ {
+ ShowIndicator( AUTO_INDICATOR_STAY_DURATION );
+ }
+ break;
+ }
+
+
+ default:
+ break;
+ }
+ }
+}
+
+void Indicator::OnStageTouched(const Dali::TouchEvent& touchEvent)
+{
+ const TouchPoint& touchPoint = touchEvent.GetPoint( 0 );
+
+ // when stage is touched while indicator is showing temporary, hide it
+ if( mIsShowing && ( CheckVisibleState() == false || mVisible == Dali::Window::AUTO ) )
+ {
+ switch( touchPoint.state )
+ {
+ case Dali::TouchPoint::Down:
+ {
+ ShowIndicator( HIDE_NOW );
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+}
+
+} // Adaptor
+} // Internal
+} // Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_INDICATOR_H__
+#define __DALI_INTERNAL_INDICATOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/images/bitmap-image.h>
+#include <dali/public-api/actors/image-actor.h>
+#include <dali/public-api/actors/mesh-actor.h>
+#include <dali/public-api/geometry/animatable-mesh.h>
+#include <window.h>
+#include <timer.h>
+#include <dali/public-api/animation/animation.h>
+#include <dali/public-api/events/pan-gesture.h>
+#include <dali/public-api/events/pan-gesture-detector.h>
+
+// INTERNAL INCLUDES
+#include <indicator-buffer.h>
+#include <server-connection.h>
+#include <shared-file.h>
+
+namespace Dali
+{
+namespace Integration
+{
+class Core;
+}
+
+namespace Internal
+{
+namespace Adaptor
+{
+class Adaptor;
+
+typedef unsigned int PixmapId;
+
+/**
+ * The Indicator class connects to the indicator server, and gets and draws the indicator
+ * for the given orientation.
+ */
+class Indicator : public ConnectionTracker, public ServerConnection::Observer
+{
+public:
+ enum State
+ {
+ DISCONNECTED,
+ CONNECTED
+ };
+
+ enum Type
+ {
+ INDICATOR_TYPE_UNKNOWN,
+ INDICATOR_TYPE_1,
+ INDICATOR_TYPE_2
+ };
+
+public:
+ class Observer
+ {
+ public:
+ /**
+ * Notify the observer if the indicator type changes
+ * @param[in] type The new indicator type
+ */
+ virtual void IndicatorTypeChanged( Type type ) = 0;
+
+ /**
+ * Notify the observer when the upload has completed.
+ * @param[in] indicator The indicator that has finished uploading.
+ */
+ virtual void IndicatorClosed(Indicator* indicator) = 0;
+ };
+
+protected:
+ /**
+ * Class to encapsulate lock file
+ */
+ class LockFile
+ {
+ public:
+ /**
+ * Constructor. open lock file
+ */
+ LockFile(const char* filename);
+
+ /**
+ * Close lock file
+ */
+ ~LockFile();
+
+ /**
+ * Grab an exclusive lock on this file
+ * @return true if the lock succeeded, false if it failed
+ */
+ bool Lock();
+
+ /**
+ * Remove the lock
+ */
+ void Unlock();
+
+ /**
+ * Test if there is an error with the lock file, and clears
+ * the error flag;
+ * @return true if an error was thrown
+ */
+ bool RetrieveAndClearErrorStatus();
+
+ private:
+ std::string mFilename;
+ int mFileDescriptor;
+ bool mErrorThrown;
+ };
+
+ /**
+ * Class to ensure lock/unlock through object destruction
+ */
+ class ScopedLock
+ {
+ public:
+ /**
+ * Constructor - creates a lock on the lockfile
+ * @param[in] lockFile The lockfile to use
+ */
+ ScopedLock( LockFile* lockFile );
+
+ /**
+ * Destructor - removes the lock (if any) on the lockfile
+ */
+ ~ScopedLock();
+
+ /**
+ * Method to test if the locking succeeded
+ * @return TRUE if locked
+ */
+ bool IsLocked();
+
+ private:
+ LockFile* mLockFile; ///< The lock file to use
+ bool mLocked; ///< Whether the lock succeeded
+ };
+
+
+public:
+ /**
+ * Constructor. Creates a new indicator and opens a connection for
+ * the required orientation.
+ * @param[in] orientation The orientation in which to draw the indicator
+ * @param[in] observer The indicator closed
+ */
+ Indicator( Adaptor* adaptor,
+ Dali::Window::WindowOrientation orientation,
+ Dali::Window::IndicatorStyle style,
+ Observer* observer );
+
+ /**
+ * Destructor
+ */
+ virtual ~Indicator();
+
+ void SetAdaptor(Adaptor* adaptor);
+
+ /**
+ * Get the actor which contains the indicator image. Ensure that the handle is
+ * released when no longer needed.
+ * Changes from the indicator service will modify the image and resize the actor appropriately.
+ * @return The indicator actor.
+ */
+ Dali::Actor GetActor();
+
+ /**
+ * Opens a new connection for the required orientation.
+ * @param[in] orientation The new orientation
+ */
+ void Open( Dali::Window::WindowOrientation orientation );
+
+ /**
+ * Close the current connection. Will respond with Observer::IndicatorClosed()
+ * when done.
+ * @note, IndicatorClosed() will be called synchronously if there's no update
+ * in progress, or asychronously if waiting for SignalUploaded )
+ */
+ void Close();
+
+ /**
+ * Set the opacity mode of the indicator background.
+ * @param[in] mode opacity mode
+ */
+ void SetOpacityMode( Dali::Window::IndicatorBgOpacity mode );
+
+ /**
+ * Set whether the indicator is visible or not.
+ * @param[in] visibleMode visible mode for indicator bar.
+ * @param[in] forceUpdate true if want to change visible mode forcely
+ */
+ void SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool forceUpdate = false );
+
+ /**
+ * Check whether the indicator is connected to the indicator service.
+ * @return whether the indicator is connected or not.
+ */
+ bool IsConnected();
+
+ /**
+ * Send message to the indicator service.
+ * @param[in] messageDomain Message Reference number
+ * @param[in] messageId Reference number of the message this message refers to
+ * @param[in] data The data to send as part of the message
+ * @param[in] size Length of the data, in bytes, to send
+ * @return whether the message is sent successfully or not
+ */
+ bool SendMessage( int messageDomain, int messageId, const void *data, int size );
+
+private:
+ /**
+ * Initialize the indicator actors
+ */
+ void Initialize();
+
+ /**
+ * Set the opacity of the background image
+ */
+ void SetBackgroundOpacity( Dali::Window::IndicatorBgOpacity opacity );
+
+ /**
+ * Touch event callback.
+ * It should pass the valid touch event to indicator server
+ *
+ * @param[in] indicator The indicator actor that was touched
+ * @param[in] touchEvent The touch event
+ */
+ bool OnTouched(Dali::Actor indicator, const TouchEvent& touchEvent);
+
+ /**
+ * Pan gesture callback.
+ * It finds flick down gesture to show hidden indicator image
+ *
+ * @param[in] actor The actor for gesture
+ * @param[in] gesture The gesture event
+ */
+ void OnPan( Dali::Actor actor, Dali::PanGesture gesture );
+
+ /**
+ * Touch event callback on stage.
+ * If stage is touched, hide showing indicator image
+ *
+ * @param[in] touchEvent The touch event
+ */
+ void OnStageTouched(const Dali::TouchEvent& touchEvent);
+
+ /**
+ * Return the given orientation in degrees
+ *
+ * @param[in] orientation The given indicator orientation
+ * @return value of 0, 90, 180 or 270
+ */
+ int OrientationToDegrees( Dali::Window::WindowOrientation orientation );
+
+ /**
+ * Connect to the indicator service matching the orientation
+ * @param[in] orientation The current indicator orientation
+ */
+ bool Connect( Dali::Window::WindowOrientation orientation );
+
+ /**
+ * Connect to the indicator service
+ * @param[in] serviceName The indicator service name
+ */
+ bool Connect( const char *serviceName );
+
+ /**
+ * Start the reconnection timer. This will run every second until we reconnect to
+ * the indicator service.
+ */
+ void StartReconnectionTimer();
+
+ /**
+ * If connection failed, attempt to re-connect every second
+ */
+ bool OnReconnectTimer();
+
+ /**
+ * Disconnect from the indicator service
+ */
+ void Disconnect();
+
+ /**
+ * Close existing lock file and open the new lock file.
+ * @param[in] epcEvent Current ecore event.
+ */
+ void NewLockFile(Ecore_Ipc_Event_Server_Data *epcEvent);
+
+ /**
+ * Handle Resize event
+ * @param[in] width The new width
+ * @param[in] height The new height
+ */
+ void Resize(int width, int height);
+
+ /**
+ * Load the shared indicator image
+ * @param[in] epcEvent The event containing the image data
+ */
+ void LoadSharedImage(Ecore_Ipc_Event_Server_Data *epcEvent);
+
+ /**
+ * Load the pixmap indicator image
+ * @param[in] epcEvent The event containing the image data
+ */
+ void LoadPixmapImage( Ecore_Ipc_Event_Server_Data *epcEvent );
+
+ /**
+ * Inform dali that the indicator data has been updated.
+ */
+ void UpdateImageData();
+
+ /**
+ * Lock the temporary file, Copy the shared image into IndicatorBuffer
+ * and then unlock the temporary file.
+ * Caller should ensure we are not writing image to gl texture.
+ */
+ bool CopyToBuffer();
+
+ /**
+ * Update the background with the correct colors
+ */
+ void SetBackground();
+
+ /**
+ * Create a new image for the indicator, and set up signal handling for it.
+ */
+ void CreateNewImage();
+
+ /**
+ * Create a new pixmap image for the indicator, and set up signal handling for it.
+ */
+ void CreateNewPixmapImage();
+
+ /**
+ * Indicator type has changed.
+ * Inform observer
+ * @param[in] type The new indicator type
+ */
+ void OnIndicatorTypeChanged( Type type );
+
+ /**
+ * Check whether the indicator could be visible or invisible
+ * @return true if indicator should be shown
+ */
+ bool CheckVisibleState();
+
+ /**
+ * Show/Hide indicator actor with effect
+ * @param[in] duration how long need to show the indicator,
+ * if it equal to 0, hide the indicator
+ * if it less than 0, show always
+ */
+ void ShowIndicator(float duration);
+
+ /**
+ * Showing timer callback
+ */
+ bool OnShowTimer();
+
+ /**
+ * Showing animation finished callback
+ * @param[in] animation
+ */
+ void OnAnimationFinished(Dali::Animation& animation);
+
+private: // Implementation of ServerConnection::Observer
+ /**
+ * @copydoc Dali::Internal::Adaptor::ServerConnection::Observer::DataReceived()
+ */
+ virtual void DataReceived(void* event);
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::ServerConnection::Observer::DataReceived()
+ */
+ virtual void ConnectionClosed();
+
+private:
+ /**
+ * Construct the gradient mesh
+ */
+ void ConstructBackgroundMesh();
+
+private:
+
+ IndicatorBufferPtr mIndicatorBuffer; ///< class which handles indicator rendering
+ PixmapId mPixmap; ///< Pixmap including indicator content
+ Dali::Image mImage; ///< Image created from mIndicatorBuffer
+ Dali::ImageActor mIndicatorImageActor; ///< Actor created from mImage
+
+ Dali::AnimatableMesh mBackgroundMesh;
+ Dali::MeshActor mBackgroundActor; ///< Actor for background
+ Dali::Actor mIndicatorActor; ///< Handle to topmost indicator actor
+ Dali::Actor mEventActor; ///< Handle to event
+ Dali::PanGestureDetector mPanDetector; ///< Pan detector to find flick gesture for hidden indicator
+ float mGestureDeltaY; ///< Checking how much panning moved
+ bool mGestureDetected; ///< Whether find the flick gesture
+
+ Dali::Timer mReconnectTimer; ///< Reconnection timer
+ SlotDelegate< Indicator > mConnection;
+
+ Dali::Window::IndicatorStyle mStyle; ///< Style of the indicator
+ Dali::Window::IndicatorBgOpacity mOpacityMode; ///< Opacity enum for background
+ Indicator::State mState; ///< The connection state
+
+ Adaptor* mAdaptor;
+ ServerConnection* mServerConnection;
+ LockFile* mLock; ///< File lock for the shared file
+ SharedFile* mSharedFile; ///< Shared file
+ Indicator::Observer* mObserver; ///< Upload observer
+
+ Dali::Window::WindowOrientation mOrientation;
+ int mRotation; ///< Orientation in degrees
+ int mImageWidth;
+ int mImageHeight;
+ Dali::Window::IndicatorVisibleMode mVisible; ///< Whether the indicator is visible
+
+ Dali::Timer mShowTimer; ///< Timer to show indicator
+ bool mIsShowing; ///< Whether the indicator is showing on the screen
+ Dali::Animation mIndicatorAnimation; ///< Animation to show/hide indicator image
+
+ bool mIsAnimationPlaying; ///< Whether the animation is playing
+};
+
+} // Adaptor
+} // Internal
+} // Dali
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "kernel-trace.h"
+
+// INTERNAL HEADERS
+#include <dali/integration-api/debug.h>
+
+// EXTERNAL HEADERS
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+const char* TRACE_MARKER_FILE = "/sys/kernel/debug/tracing/trace_marker";
+const char* SPI_PREFIX = "SPI_EV_DALI_"; ///< prefix to let the SPI tool know it should read the trace
+}// un-named name space
+
+KernelTrace::KernelTrace()
+: mFileDescriptor( 0 ),
+ mLoggedError( false )
+{
+}
+
+KernelTrace::~KernelTrace()
+{
+ if( mFileDescriptor )
+ {
+ close( mFileDescriptor );
+ }
+}
+
+// If this function doesn't appear to work, you can test manually on the device.
+// $ cd /sys/kernel/debug/tracing
+//
+// If the folder doesn't exist then the kernel needs to be re-built with ftrace enabled
+// If it does exist, then you can continue to test ftrace is working:
+//
+// $ echo 1 > tracing_enabled
+// $ echo "test" > trace_marker
+// $ cat trace
+// should print out test message
+// If the message did not get added to the trace, then check you have write permissions to the trace_marker file.
+//
+//
+void KernelTrace::Trace( const std::string& traceMessage )
+{
+ // Open the trace_marker file
+ if( mFileDescriptor == 0 )
+ {
+ mFileDescriptor = open( TRACE_MARKER_FILE , O_WRONLY);
+ if( mFileDescriptor == -1 )
+ {
+ // we want to keep trying to open it, so it will start working if someone fixes
+ // the permissions on the trace marker
+ mFileDescriptor = 0;
+
+ // first time we fail to open the file, log an error
+ if( !mLoggedError )
+ {
+ mLoggedError = true;
+ DALI_LOG_ERROR("Failed to open /sys/kernel/debug/tracing/trace_marker for writing please check file permissions.");
+ }
+
+ }
+ }
+
+ if( mFileDescriptor > 0 )
+ {
+ std::string msg( SPI_PREFIX );
+ msg+=traceMessage;
+
+ int ret = write( mFileDescriptor, msg.c_str(), msg.length() );
+ // if it failed then close the file description and try again next time we trace
+ if( ret < 0 )
+ {
+ close( mFileDescriptor );
+ mFileDescriptor = 0;
+ }
+ }
+}
+
+} // namespace Internal
+
+} // namespace Adaptor
+
+} // namespace Dali
+
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_KERNEL_TRACE_H__
+#define __DALI_INTERNAL_ADAPTOR_KERNEL_TRACE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <base/interfaces/kernel-trace-interface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Concrete Kernel Tracing Interface.
+ * Used to log trace messages to the kernel using ftrace.
+ *
+ */
+class KernelTrace : public KernelTraceInterface
+{
+public:
+
+ /**
+ * Constructor
+ */
+ KernelTrace();
+
+ /**
+ * Destructor
+ */
+ virtual ~KernelTrace();
+
+ /**
+ * @copydoc KernelTracerInterface::KernelTrace()
+ */
+ virtual void Trace( const std::string& traceMessage );
+
+private:
+
+ int mFileDescriptor;
+ bool mLoggedError:1;
+
+};
+
+} // namespace Internal
+
+} // namespace Adaptor
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ADAPTOR_KERNEL_TRACE_H__
--- /dev/null
+#ifndef __DALI_KEY_IMPL_H__
+#define __DALI_KEY_IMPL_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <key.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Implementation of the Key matching
+ */
+namespace KeyLookup
+{
+
+/**
+ * @copydoc Dali::IsKey()
+ */
+bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey);
+
+/**
+ * Check if a the given key name string is a button on the device itself.
+ * @param keyName A pointer to the key name
+ * @return true if the key is matched, false if not
+ */
+bool IsDeviceButton( const char* keyName );
+
+} // namespace KeyLookup
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_KEY_IMPL_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <key.h>
+
+// INTERNAL INCLUDES
+#include <key-impl.h>
+
+namespace Dali
+{
+
+bool IsKey( const KeyEvent& keyEvent, KEY daliKey)
+{
+ return Internal::Adaptor::KeyLookup::IsKey( keyEvent, daliKey );
+}
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "livebox-plugin.h"
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+#include <livebox-plugin-impl.h>
+
+namespace Dali
+{
+
+LiveboxPlugin::LiveboxPlugin( int* argc, char **argv[] )
+{
+ mImpl = new Internal::Adaptor::LiveboxPlugin(*this, argc, argv, "Dali Livebox", DeviceLayout::DEFAULT_BASE_LAYOUT);
+}
+
+LiveboxPlugin::LiveboxPlugin( int* argc, char **argv[], const std::string& name )
+{
+ mImpl = new Internal::Adaptor::LiveboxPlugin(*this, argc, argv, name, DeviceLayout::DEFAULT_BASE_LAYOUT);
+}
+
+LiveboxPlugin::LiveboxPlugin(int* argc, char **argv[], const DeviceLayout& baseLayout)
+{
+ mImpl = new Internal::Adaptor::LiveboxPlugin(*this, argc, argv, "Dali Livebox", baseLayout);
+}
+
+LiveboxPlugin::LiveboxPlugin(int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout)
+{
+ mImpl = new Internal::Adaptor::LiveboxPlugin(*this, argc, argv, name, baseLayout);
+}
+
+LiveboxPlugin::~LiveboxPlugin()
+{
+ delete mImpl;
+}
+
+void LiveboxPlugin::SetTitle(const std::string& title)
+{
+ mImpl->SetTitle(title);
+}
+
+void LiveboxPlugin::SetContent(const std::string& content)
+{
+ mImpl->SetContent(content);
+}
+
+const PositionSize& LiveboxPlugin::GetGlanceBarGeometry() const
+{
+ return mImpl->GetGlanceBarGeometry();
+}
+
+const GlanceBarEventInfo& LiveboxPlugin::GetGlanceBarEventInfo() const
+{
+ return mImpl->GetGlanceBarEventInfo();
+}
+
+LiveboxSizeType LiveboxPlugin::GetLiveboxSizeType() const
+{
+ return mImpl->GetLiveboxSizeType();
+}
+
+void LiveboxPlugin::Run()
+{
+ mImpl->Run();
+}
+
+void LiveboxPlugin::Quit()
+{
+ mImpl->Quit();
+}
+
+bool LiveboxPlugin::AddIdle(boost::function<void(void)> callBack)
+{
+ return mImpl->AddIdle(callBack);
+}
+
+LiveboxPlugin& LiveboxPlugin::Get()
+{
+ return Internal::Adaptor::LiveboxPlugin::Get();
+}
+
+LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::InitializedSignal()
+{
+ return mImpl->InitializedSignal();
+}
+
+LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::TerminatedSignal()
+{
+ return mImpl->TerminatedSignal();
+}
+
+LiveboxPlugin::LiveboxPluginSignal LiveboxPlugin::SignalTerminated()
+{
+ return mImpl->SignalTerminated();
+}
+
+LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::PausedSignal()
+{
+ return mImpl->PausedSignal();
+}
+
+LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::ResumedSignal()
+{
+ return mImpl->ResumedSignal();
+}
+LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::ResizedSignal()
+{
+ return mImpl->ResizedSignal();
+}
+
+LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::GlanceCreatedSignal()
+{
+ return mImpl->GlanceCreatedSignal();
+}
+
+LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::GlanceDestroyedSignal()
+{
+ return mImpl->GlanceDestroyedSignal();
+}
+
+LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::GlanceTouchedSignal()
+{
+ return mImpl->GlanceTouchedSignal();
+}
+
+LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::GlanceMovedSignal()
+{
+ return mImpl->GlanceMovedSignal();
+}
+
+LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::GlanceScriptEventSignal()
+{
+ return mImpl->GlanceScriptEventSignal();
+}
+
+LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::LanguageChangedSignal()
+{
+ return mImpl->LanguageChangedSignal();
+}
+
+} // namespace Dali
+
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "locale-utils.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace Locale
+{
+
+using Dali::VirtualKeyboard::TextDirection;
+using Dali::VirtualKeyboard::LeftToRight;
+using Dali::VirtualKeyboard::RightToLeft;
+
+namespace
+{
+
+struct LocaleDirection
+{
+ const char * locale;
+ const char * name;
+ TextDirection direction;
+};
+
+const LocaleDirection LOCALE_DIRECTION_LOOKUP_TABLE[] =
+{
+ { "af", "Afrikaans", LeftToRight },
+ { "am", "Amharic", LeftToRight },
+ { "ar", "Arabic", RightToLeft },
+ { "as", "Assamese", LeftToRight },
+ { "az", "Azeri", LeftToRight },
+ { "be", "Belarusian", LeftToRight },
+ { "bg", "Bulgarian", LeftToRight },
+ { "bn", "Bengali", LeftToRight },
+ { "bo", "Tibetan", LeftToRight },
+ { "bs", "Bosnian", LeftToRight },
+ { "ca", "Catalan", LeftToRight },
+ { "cs", "Czech", LeftToRight },
+ { "cy", "Welsh", LeftToRight },
+ { "da", "Danish", LeftToRight },
+ { "de", "German", LeftToRight },
+ { "dv", "Divehi", RightToLeft },
+ { "el", "Greek", LeftToRight },
+ { "en", "English", LeftToRight },
+ { "es", "Spanish", LeftToRight },
+ { "et", "Estonian", LeftToRight },
+ { "eu", "Basque", LeftToRight },
+ { "fa", "Farsi", RightToLeft },
+ { "fi", "Finnish", LeftToRight },
+ { "fo", "Faroese", LeftToRight },
+ { "fr", "French", LeftToRight },
+ { "gd", "Gaelic", LeftToRight },
+ { "gl", "Galician", LeftToRight },
+ { "gn", "Guarani", LeftToRight },
+ { "gu", "Gujarati", LeftToRight },
+ { "he", "Hebrew", RightToLeft },
+ { "hi", "Hindi", LeftToRight },
+ { "hr", "Croatian", LeftToRight },
+ { "hu", "Hungarian", LeftToRight },
+ { "hy", "Armenian", LeftToRight },
+ { "id", "Indonesian", LeftToRight },
+ { "is", "Icelandic", LeftToRight },
+ { "it", "Italian", LeftToRight },
+ { "ja", "Japanese", LeftToRight },
+ { "ka", "Georgian", LeftToRight },
+ { "kk", "Kazakh", RightToLeft },
+ { "km", "Khmer", LeftToRight },
+ { "kn", "Kannada", LeftToRight },
+ { "ko", "Korean", LeftToRight },
+ { "ks", "Kashmiri", RightToLeft },
+ { "la", "Latin", LeftToRight },
+ { "lo", "Lao", LeftToRight },
+ { "lt", "Lithuanian", LeftToRight },
+ { "lv", "Latvian", LeftToRight },
+ { "mi", "Maori", LeftToRight },
+ { "mk", "FYRO Macedonia", LeftToRight },
+ { "ml", "Malayalam", LeftToRight },
+ { "mn", "Mongolian", LeftToRight },
+ { "mr", "Marathi", LeftToRight },
+ { "ms", "Malay", LeftToRight },
+ { "mt", "Maltese", LeftToRight },
+ { "my", "Burmese", LeftToRight },
+ { "nb", "Norwegian: Bokml", LeftToRight },
+ { "ne", "Nepali", LeftToRight },
+ { "nl", "Dutch", LeftToRight },
+ { "nn", "Norwegian: Nynorsk", LeftToRight },
+ { "or", "Oriya", LeftToRight },
+ { "pa", "Punjabi", LeftToRight },
+ { "pl", "Polish", LeftToRight },
+ { "pt", "Portuguese", LeftToRight },
+ { "rm", "Raeto-Romance", LeftToRight },
+ { "ro", "Romanian", LeftToRight },
+ { "ru", "Russian", LeftToRight },
+ { "sa", "Sanskrit", LeftToRight },
+ { "sb", "Sorbian", LeftToRight },
+ { "sd", "Sindhi", LeftToRight },
+ { "si", "Sinhala", LeftToRight },
+ { "sk", "Slovak", LeftToRight },
+ { "sl", "Slovenian", LeftToRight },
+ { "so", "Somali", LeftToRight },
+ { "sq", "Albanian", LeftToRight },
+ { "sr", "Serbian", LeftToRight },
+ { "sv", "Swedish", LeftToRight },
+ { "sw", "Swahili", LeftToRight },
+ { "ta", "Tamil", LeftToRight },
+ { "te", "Telugu", LeftToRight },
+ { "tg", "Tajik", RightToLeft },
+ { "th", "Thai", LeftToRight },
+ { "tk", "Turkmen", LeftToRight },
+ { "tn", "Setsuana", LeftToRight },
+ { "tr", "Turkish", LeftToRight },
+ { "ts", "Tsonga", LeftToRight },
+ { "tt", "Tatar", LeftToRight },
+ { "uk", "Ukrainian", LeftToRight },
+ { "ur", "Urdu", RightToLeft },
+ { "uz", "Uzbek", LeftToRight },
+ { "vi", "Vietnamese", LeftToRight },
+ { "xh", "Xhosa", LeftToRight },
+ { "yi", "Yiddish", RightToLeft },
+ { "zh", "Chinese", LeftToRight },
+ { "zu", "Zulu", LeftToRight },
+
+ { NULL, NULL, LeftToRight }
+};
+
+} // unnamed namespace
+
+TextDirection GetTextDirection( std::string locale )
+{
+ TextDirection direction( LeftToRight );
+
+ if ( !locale.empty() && locale.size() > 2 )
+ {
+ // We're only interested in the first two characters
+ locale.resize(2);
+
+ for ( const LocaleDirection* iter = &LOCALE_DIRECTION_LOOKUP_TABLE[0]; iter->locale; ++iter )
+ {
+ if ( !locale.compare( iter->locale ) )
+ {
+ direction = iter->direction;
+ break;
+ }
+ }
+ }
+
+ return direction;
+}
+
+} // namespace Locale
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_LOCALE_UTILS_H__
+#define __DALI_INTERNAL_LOCALE_UTILS_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <virtual-keyboard.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace Locale
+{
+
+Dali::VirtualKeyboard::TextDirection GetTextDirection( std::string locale );
+
+} // namespace Locale
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_LOCALE_UTILS_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "native-bitmap-buffer-impl.h"
+
+// EXTERNAL HEADERS
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/bitmap.h>
+
+// INTERNAL HEADERS
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+NativeBitmapBuffer::NativeBitmapBuffer( Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pFormat )
+: mWidth(width),
+ mHeight(height),
+ mPixelFormat(pFormat),
+ mLastReadBuffer(NULL)
+{
+ DALI_ASSERT_ALWAYS( adaptor );
+ mBuffer = new Integration::LocklessBuffer( width * height * Pixel::GetBytesPerPixel(pFormat) );
+ mGlAbstraction = &(adaptor->GetGlAbstraction());
+}
+
+NativeBitmapBuffer::~NativeBitmapBuffer()
+{
+ delete mBuffer;
+}
+
+void NativeBitmapBuffer::PrepareTexture()
+{
+ DALI_ASSERT_ALWAYS( mBuffer );
+ GLenum pixelFormat = GL_RGBA;
+ GLenum pixelDataType = GL_UNSIGNED_BYTE;
+
+ Integration::ConvertToGlFormat( mPixelFormat, pixelDataType, pixelFormat );
+
+ const unsigned char* buf = mBuffer->Read();
+
+ if( buf && buf != mLastReadBuffer ) // Prevent same buffer being uploaded multiple times
+ {
+ mLastReadBuffer = buf;
+
+ // The active texture has already been set to a sampler and bound.
+ mGlAbstraction->TexImage2D( GL_TEXTURE_2D, 0, pixelFormat, mWidth, mHeight, 0, pixelFormat, pixelDataType, buf );
+ }
+}
+
+void NativeBitmapBuffer::Write( const unsigned char *src, size_t size )
+{
+ mBuffer->Write( src, size ); // Write will cause LocklessBuffer to switch to the other buffer
+}
+
+bool NativeBitmapBuffer::GlExtensionCreate()
+{
+ return true;
+}
+
+void NativeBitmapBuffer::GlExtensionDestroy()
+{
+}
+
+unsigned int NativeBitmapBuffer::TargetTexture()
+{
+ return 0;
+}
+
+unsigned int NativeBitmapBuffer::GetWidth() const
+{
+ return mWidth;
+}
+
+unsigned int NativeBitmapBuffer::GetHeight() const
+{
+ return mHeight;
+}
+
+Pixel::Format NativeBitmapBuffer::GetPixelFormat() const
+{
+ return mPixelFormat;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_NATIVE_BITMAP_BUFFER_H__
+#define __DALI_NATIVE_BITMAP_BUFFER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL HEADERS
+#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/images/pixel.h>
+#include <dali/integration-api/gl-abstraction.h>
+#include <dali/integration-api/lockless-buffer.h>
+#include <dali/public-api/common/dali-vector.h>
+
+// INTERNAL HEADERS
+#include <adaptor-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class NativeBitmapBuffer;
+typedef IntrusivePtr<NativeBitmapBuffer> NativeBitmapBufferPtr;
+
+/**
+ * A Bitmap-based implementation of the NativeImage interface.
+ */
+class NativeBitmapBuffer : public NativeImage
+{
+
+public:
+ /**
+ * Constructor.
+ * @param adaptor Adaptor used
+ * @param width width of image
+ * @param height height of image
+ * @param pixelFormat pixel format for image
+ */
+ NativeBitmapBuffer( Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pixelFormat );
+
+ /**
+ * virtual destructor
+ */
+ virtual ~NativeBitmapBuffer();
+
+ /**
+ * Write to buffer. Does not block.
+ * @param[in] src data source
+ * @param[in] size size of data in bytes
+ * @return true if successful, false if currently reading from buffer in render thread
+ */
+ void Write( const unsigned char* src, size_t size );
+
+public:
+ /**
+ * @copydoc Dali::NativeImage::GlExtensionCreate()
+ */
+ virtual bool GlExtensionCreate();
+
+ /**
+ * @copydoc Dali::NativeImage::GlExtensionDestroy()
+ */
+ virtual void GlExtensionDestroy();
+
+ /**
+ * @copydoc Dali::NativeImage::TargetTexture()
+ */
+ virtual unsigned int TargetTexture();
+
+ /**
+ * @copydoc Dali::NativeImage::PrepareTexture()
+ */
+ virtual void PrepareTexture();
+
+ /**
+ * @copydoc Dali::NativeImage::GetWidth()
+ */
+ virtual unsigned int GetWidth() const;
+
+ /**
+ * @copydoc Dali::NativeImage::GetHeight()
+ */
+ virtual unsigned int GetHeight() const;
+
+ /**
+ * @copydoc Dali::NativeImage::GetPixelFormat()
+ */
+ virtual Pixel::Format GetPixelFormat() const;
+
+private:
+ NativeBitmapBuffer( const NativeBitmapBuffer& ); ///< not defined
+ NativeBitmapBuffer& operator =( const NativeBitmapBuffer& ); ///< not defined
+ NativeBitmapBuffer(); ///< not defined
+
+private:
+ Integration::GlAbstraction* mGlAbstraction; ///< GlAbstraction used
+
+ Integration::LocklessBuffer* mBuffer; ///< bitmap data double buffered
+ unsigned int mWidth; ///< Image width
+ unsigned int mHeight; ///< Image height
+ Pixel::Format mPixelFormat; ///< Image pixelformat
+ const unsigned char* mLastReadBuffer; ///< last buffer that was read
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_NATIVE_BITMAP_BUFFER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "object-profiler.h"
+#include <stdlib.h>
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/profiling.h>
+#include <dali/public-api/actors/image-actor.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/type-registry.h>
+
+using std::string;
+using namespace Dali::Integration::Profiling;
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+ObjectProfiler::ObjectProfiler()
+: mIsActive(false)
+{
+ // This class must be created after the Stage; this means it doesn't count the initial objects
+ // that are created by the stage (base layer, default camera actor)
+ mObjectRegistry = Dali::Stage::GetCurrent().GetObjectRegistry();
+
+ char* profile = getenv("PROFILE_DALI_OBJECTS");
+ if( profile != NULL )
+ {
+ mIsActive = true;
+ int timeInterval = atoi(profile);
+ if( timeInterval > 0 )
+ {
+ mTimer = Dali::Timer::New(timeInterval*1000);
+ mTimer.TickSignal().Connect( this, &ObjectProfiler::OnTimeout );
+ mTimer.Start();
+ }
+
+ mObjectRegistry.ObjectCreatedSignal().Connect( this, &ObjectProfiler::OnObjectCreated );
+ mObjectRegistry.ObjectDestroyedSignal().Connect( this, &ObjectProfiler::OnObjectDestroyed );
+ }
+}
+
+ObjectProfiler::~ObjectProfiler()
+{
+}
+
+void ObjectProfiler::DisplayInstanceCounts()
+{
+ InstanceCountMapIterator iter = mInstanceCountMap.begin();
+ InstanceCountMapIterator end = mInstanceCountMap.end();
+
+ for( ; iter != end; iter++ )
+ {
+ int memorySize = GetMemorySize(iter->first, iter->second);
+ if( memorySize > 0 )
+ {
+ LogMessage( Debug::DebugInfo, "%-30s: % 4d Memory MemorySize: ~% 6.1f kB\n",
+ iter->first.c_str(), iter->second, memorySize / 1024.0f );
+ }
+ else
+ {
+ LogMessage( Debug::DebugInfo, "%-30s: % 4d\n",
+ iter->first.c_str(), iter->second );
+ }
+ }
+ LogMessage(Debug::DebugInfo, "\n");
+
+ int quadCount = 0;
+
+ // Count number of quads:
+
+ for( InstanceTypes::iterator iter = mInstanceTypes.begin(), end = mInstanceTypes.end(); iter != end; ++iter )
+ {
+ if( iter->second.compare("ImageActor") == 0 )
+ {
+ BaseHandle handle(iter->first);
+ Dali::ImageActor imageActor = Dali::ImageActor::DownCast(handle);
+ if( imageActor )
+ {
+ if( imageActor.GetStyle() == Dali::ImageActor::STYLE_QUAD )
+ {
+ quadCount++;
+ }
+ }
+ }
+ }
+
+ LogMessage(Debug::DebugInfo, "Number of image actors using Quad style: %d\n", quadCount);
+}
+
+bool ObjectProfiler::OnTimeout()
+{
+ DisplayInstanceCounts();
+ return true;
+}
+
+void ObjectProfiler::OnObjectCreated(BaseHandle handle)
+{
+ string theType = handle.GetTypeName();
+ if( theType.empty() )
+ {
+ DALI_LOG_ERROR("Object created from an unregistered type\n");
+ theType = "<Unregistered>";
+ }
+
+ mInstanceTypes.push_back(InstanceTypePair(&handle.GetBaseObject(), theType));
+
+ InstanceCountMapIterator iter = mInstanceCountMap.find(theType);
+ if( iter == mInstanceCountMap.end() )
+ {
+ InstanceCountPair instanceCount(theType, 1);
+ mInstanceCountMap.insert(instanceCount);
+ }
+ else
+ {
+ iter->second++;
+ }
+}
+
+void ObjectProfiler::OnObjectDestroyed(const Dali::RefObject* object)
+{
+ const BaseObject* baseObject = static_cast<const BaseObject*>(object);
+
+ InstanceTypes::iterator end = mInstanceTypes.end();
+ for( InstanceTypes::iterator iter = mInstanceTypes.begin(); iter != end; iter++)
+ {
+ if( iter->first == baseObject )
+ {
+ const std::string& theType = iter->second;
+ if( !theType.empty() )
+ {
+ InstanceCountMapIterator countIter = mInstanceCountMap.find(theType);
+ if( countIter != mInstanceCountMap.end() )
+ {
+ countIter->second--;
+ }
+ }
+ mInstanceTypes.erase( iter );
+ break;
+ }
+ }
+}
+
+int ObjectProfiler::GetMemorySize(const std::string& name, int count)
+{
+ struct MemoryMemorySize
+ {
+ std::string name;
+ int memorySize;
+ };
+ MemoryMemorySize memoryMemorySizes[] =
+ {
+ { "Animation", ANIMATION_MEMORY_SIZE },
+ { "Constraint", CONSTRAINT_MEMORY_SIZE },
+ { "Actor", ACTOR_MEMORY_SIZE },
+ { "Layer", LAYER_MEMORY_SIZE },
+ { "CameraActor", CAMERA_ACTOR_MEMORY_SIZE },
+ { "ImageActor", IMAGE_ACTOR_MEMORY_SIZE },
+ { "TextActor", TEXT_ACTOR_MEMORY_SIZE },
+ { "MeshActor", MESH_ACTOR_MEMORY_SIZE },
+ { "Image", IMAGE_MEMORY_SIZE },
+ { "Mesh", MESH_MEMORY_SIZE },
+ { "Material", MATERIAL_MEMORY_SIZE },
+ };
+
+ for( size_t i=0; i<sizeof(memoryMemorySizes)/sizeof(MemoryMemorySize); i++ )
+ {
+ if( memoryMemorySizes[i].name.compare(name) == 0 )
+ {
+ return count * memoryMemorySizes[i].memorySize;
+ }
+ }
+ return 0;
+}
+
+} // Adaptor
+} // Internal
+} // Dali
--- /dev/null
+#ifndef __DALI_ADAPTOR_OBJECT_PROFILER_H__
+#define __DALI_ADAPTOR_OBJECT_PROFILER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/public-api/object/object-registry.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/common/map-wrapper.h>
+#include <dali/public-api/signals/connection-tracker.h>
+#include <timer.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+/**
+ * Class to profile the number of instances of Objects in the system
+ */
+class ObjectProfiler : public ConnectionTracker
+{
+public:
+ /**
+ * Constructor
+ */
+ ObjectProfiler();
+
+ /**
+ * Destructor
+ */
+ ~ObjectProfiler();
+
+ /**
+ * Display a list of types with the current number of instances in the system
+ */
+ void DisplayInstanceCounts();
+
+private:
+ /**
+ * If timer is running, display the instance counts
+ */
+ bool OnTimeout();
+
+ /**
+ * Callback used when objects are created. Increases instance count for that object type
+ * @param[in] handle of the created object
+ */
+ void OnObjectCreated(BaseHandle handle);
+
+ /**
+ * Callback used when objects are created. Decreases instance count for that object type
+ * @param[in] object The object being destroyed
+ */
+ void OnObjectDestroyed(const Dali::RefObject* object);
+
+ /**
+ * Get the memory size of the given object
+ */
+ int GetMemorySize(const std::string& name, int count);
+
+private:
+ typedef std::map<std::string, int> InstanceCountMap;
+ typedef std::pair<const std::string, int> InstanceCountPair;
+ typedef InstanceCountMap::iterator InstanceCountMapIterator;
+ typedef std::pair<BaseObject*, std::string> InstanceTypePair;
+ typedef std::vector<InstanceTypePair> InstanceTypes;
+
+ Dali::ObjectRegistry mObjectRegistry;
+ Dali::Timer mTimer;
+ InstanceCountMap mInstanceCountMap;
+ InstanceTypes mInstanceTypes;
+ bool mIsActive;
+};
+
+} // Adaptor
+} // Internal
+} // Dali
+
+#endif // __DALI_ADAPTOR_OBJECT_PROFILER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "orientation-impl.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <window-impl.h>
+#include <adaptor-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+Orientation* Orientation::New(Window* window)
+{
+ Orientation* orientation = new Orientation(window);
+
+ return orientation;
+}
+
+Orientation::Orientation(Window* window)
+: mWindow(window),
+ mOrientation(0),
+ mWindowWidth(0),
+ mWindowHeight(0)
+{
+}
+
+Orientation::~Orientation()
+{
+ // Note, there is only one orientation object that's owned by window,
+ // so it will live longer than adaptor. (hence, no need to remove rotation observer)
+}
+
+void Orientation::SetAdaptor(Dali::Adaptor& adaptor)
+{
+ Adaptor::GetImplementation(adaptor).SetRotationObserver(this);
+}
+
+int Orientation::GetDegrees() const
+{
+ return mOrientation;
+}
+
+float Orientation::GetRadians() const
+{
+ return Math::PI * (float)mOrientation / 180.0f;
+}
+
+Orientation::OrientationSignalV2& Orientation::ChangedSignal()
+{
+ return mChangedSignal;
+}
+
+void Orientation::OnRotationPrepare( const RotationEvent& rotation )
+{
+ mOrientation = rotation.angle;
+ mWindowWidth = rotation.width;
+ mWindowHeight = rotation.height;
+}
+
+void Orientation::OnRotationRequest()
+{
+ // Emit signal
+ if( !mChangedSignal.Empty() )
+ {
+ Dali::Orientation handle( this );
+ mChangedSignal.Emit( handle );
+ }
+
+ if( mWindow != NULL )
+ {
+ mWindow->RotationDone( mOrientation, mWindowWidth, mWindowHeight );
+ }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ORIENTATION_H__
+#define __DALI_INTERNAL_ORIENTATION_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <cmath>
+#include <dali/public-api/common/constants.h>
+#include <dali/public-api/object/base-object.h>
+#include <orientation.h>
+
+// INTERNAL INCLUDES
+#include <rotation-observer.h>
+
+namespace Dali
+{
+class Adaptor;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class Window;
+class Orientation;
+
+typedef IntrusivePtr<Orientation> OrientationPtr;
+
+class Orientation : public BaseObject, public RotationObserver
+{
+public:
+
+ typedef Dali::Orientation::OrientationSignalV2 OrientationSignalV2;
+
+ static Orientation* New(Window* window);
+
+ /**
+ * Constructor
+ */
+ Orientation(Window* window);
+
+protected:
+ /**
+ * Destructor
+ */
+ virtual ~Orientation();
+
+public:
+ /**
+ * Set the adaptor for basic setup
+ * @param[in] adaptor The adaptor
+ */
+ void SetAdaptor(Dali::Adaptor& adaptor);
+
+ /**
+ * Returns the actual orientation in degrees
+ * @return The device's orientation
+ */
+ int GetDegrees() const;
+
+ /**
+ * Returns the actual orientation in radians
+ * @return The device's orientation
+ */
+ float GetRadians() const;
+
+public: // Signals
+
+ /**
+ * @copydoc Dali::Orientation::ChangedSignal()
+ */
+ OrientationSignalV2& ChangedSignal();
+
+private:
+ /**
+ * @copydoc Dali::Internal::Adaptor::RotationObserver::OnRotationPrepare()
+ */
+ virtual void OnRotationPrepare( const RotationEvent& rotation );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RotationObserver::OnRotationRequest()
+ */
+ virtual void OnRotationRequest( );
+
+ // Undefined
+ Orientation(const Orientation&);
+ Orientation& operator=(Orientation&);
+
+private:
+ /**
+ * Signals and sends event of orientation change.
+ */
+ void EmitOrientationChange();
+
+private:
+
+ Window* mWindow;
+
+ OrientationSignalV2 mChangedSignal;
+
+ int mOrientation;
+ int mWindowWidth;
+ int mWindowHeight;
+};
+
+inline Orientation& GetImplementation (Dali::Orientation& orientation)
+{
+ DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
+
+ BaseObject& handle = orientation.GetBaseObject();
+
+ return static_cast<Orientation&>(handle);
+}
+
+inline const Orientation& GetImplementation(const Dali::Orientation& orientation)
+{
+ DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
+
+ const BaseObject& handle = orientation.GetBaseObject();
+
+ return static_cast<const Orientation&>(handle);
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ORIENTATION_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <orientation.h>
+
+// INTERNAL INCLUDES
+#include <orientation-impl.h>
+
+namespace Dali
+{
+
+Orientation::Orientation()
+{
+}
+
+Orientation::~Orientation()
+{
+}
+
+int Orientation::GetDegrees() const
+{
+ return Internal::Adaptor::GetImplementation(*this).GetDegrees();
+}
+
+float Orientation::GetRadians() const
+{
+ return Internal::Adaptor::GetImplementation(*this).GetRadians();
+}
+
+Orientation::OrientationSignalV2& Orientation::ChangedSignal()
+{
+ return Internal::Adaptor::GetImplementation(*this).ChangedSignal();
+}
+
+Orientation::Orientation( Internal::Adaptor::Orientation* orientation )
+: BaseHandle(orientation)
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+// CLASS HEADER
+#include <physical-keyboard-impl.h>
+
+// INTERNAL INCLUDES
+#include <adaptor-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+Dali::PhysicalKeyboard PhysicalKeyboard::New()
+{
+ Dali::PhysicalKeyboard keyboardHandle;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ Dali::Adaptor& adaptor = Adaptor::Get();
+ keyboardHandle = Dali::PhysicalKeyboard( new PhysicalKeyboard() );
+ adaptor.RegisterSingleton( typeid( keyboardHandle ), keyboardHandle );
+ }
+
+ return keyboardHandle;
+}
+
+Dali::PhysicalKeyboard PhysicalKeyboard::Get()
+{
+ Dali::PhysicalKeyboard keyboardHandle;
+
+ // Ensure the adaptor has been created
+ if ( Adaptor::IsAvailable() )
+ {
+ Dali::Adaptor& adaptor = Adaptor::Get();
+
+ BaseHandle handle = adaptor.GetSingleton( typeid( Dali::PhysicalKeyboard ) );
+ if( handle )
+ {
+ // If so, downcast the handle of singleton to focus manager
+ keyboardHandle = Dali::PhysicalKeyboard( dynamic_cast< PhysicalKeyboard* >( handle.GetObjectPtr() ) );
+ }
+ }
+
+ return keyboardHandle;
+}
+
+bool PhysicalKeyboard::IsAttached() const
+{
+ return mAttached;
+}
+
+void PhysicalKeyboard::KeyReceived( bool fromPhysicalKeyboard )
+{
+ if ( mAttached != fromPhysicalKeyboard )
+ {
+ mAttached = fromPhysicalKeyboard;
+
+ Dali::PhysicalKeyboard handle( this );
+ mStatusChangedSignal.Emit( handle );
+ }
+}
+
+PhysicalKeyboard::~PhysicalKeyboard()
+{
+}
+
+PhysicalKeyboard::PhysicalKeyboard()
+: mAttached( false )
+{
+}
+
+} // Adaptor
+
+} // Internal
+
+} // Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_PHYSICAL_KEYBOARD_H__
+#define __DALI_INTERNAL_PHYSICAL_KEYBOARD_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <physical-keyboard.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class PhysicalKeyboard : public BaseObject
+{
+public:
+
+ /**
+ * Creates a new instance of the PhysicalKeyboard.
+ */
+ static Dali::PhysicalKeyboard New();
+
+ /**
+ * Gets the singleton instance of the Physical Keyboard.
+ */
+ static Dali::PhysicalKeyboard Get();
+
+ /**
+ * @copydoc Dali::PhysicalKeyboard::IsAttached()
+ */
+ bool IsAttached() const;
+
+ /**
+ * Should be called by the EventHandler when a key is received. If it's received from a physical
+ * keyboard then the parameter should be true.
+ * @param[in] fromPhysicalKeyboard true if received from a physical keyboard, false otherwise.
+ */
+ void KeyReceived( bool fromPhysicalKeyboard );
+
+ // Signals
+
+ /**
+ * @copydoc Dali::PhysicalKeyboard::StatusChangedSignal()
+ */
+ Dali::PhysicalKeyboard::Signal& StatusChangedSignal() { return mStatusChangedSignal; }
+
+protected:
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~PhysicalKeyboard();
+
+private:
+
+ // Undefined
+ PhysicalKeyboard( const PhysicalKeyboard& );
+ PhysicalKeyboard& operator=( PhysicalKeyboard& );
+
+ /**
+ * Constructor
+ */
+ PhysicalKeyboard();
+
+private:
+
+ Dali::PhysicalKeyboard::Signal mStatusChangedSignal; ///< Status changed signal
+ bool mAttached; ///< true if the physical keyboard is attached, false otherwise
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline static Internal::Adaptor::PhysicalKeyboard& GetImplementation( PhysicalKeyboard& keyboard )
+{
+ DALI_ASSERT_ALWAYS( keyboard && "PhysicalKeyboard handle is empty" );
+
+ BaseObject& handle = keyboard.GetBaseObject();
+
+ return static_cast< Internal::Adaptor::PhysicalKeyboard& >( handle );
+}
+
+inline static const Internal::Adaptor::PhysicalKeyboard& GetImplementation( const PhysicalKeyboard& keyboard )
+{
+ DALI_ASSERT_ALWAYS( keyboard && "PhysicalKeyboard handle is empty" );
+
+ const BaseObject& handle = keyboard.GetBaseObject();
+
+ return static_cast< const Internal::Adaptor::PhysicalKeyboard& >( handle );
+}
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_PHYSICAL_KEYBOARD_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <physical-keyboard.h>
+
+// INTERNAL INCLUDES
+#include <physical-keyboard-impl.h>
+
+namespace Dali
+{
+
+PhysicalKeyboard::PhysicalKeyboard()
+{
+}
+
+PhysicalKeyboard::~PhysicalKeyboard()
+{
+}
+
+PhysicalKeyboard PhysicalKeyboard::Get()
+{
+ // Get the physical keyboard handle
+ PhysicalKeyboard handle = Internal::Adaptor::PhysicalKeyboard::Get();
+
+ // If it's not been created then create one
+ if ( !handle )
+ {
+ handle = Internal::Adaptor::PhysicalKeyboard::New();
+ }
+
+ return handle;
+}
+
+bool PhysicalKeyboard::IsAttached() const
+{
+ return GetImplementation( *this ).IsAttached();
+}
+
+PhysicalKeyboard::Signal& PhysicalKeyboard::StatusChangedSignal()
+{
+ return GetImplementation( *this ).StatusChangedSignal();
+}
+
+PhysicalKeyboard::PhysicalKeyboard( Internal::Adaptor::PhysicalKeyboard *impl )
+: BaseHandle(impl)
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <pixmap-image.h>
+
+// INTERNAL INCLUDES
+#include <pixmap-image-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/any.h>
+
+namespace Dali
+{
+
+PixmapImagePtr PixmapImage::New(unsigned int width, unsigned int height, ColorDepth depth, Adaptor& adaptor)
+{
+ Any empty;
+ PixmapImagePtr image = new PixmapImage(width, height, depth, adaptor, empty);
+ return image;
+}
+
+PixmapImagePtr PixmapImage::New(Any pixmap, Adaptor& adaptor)
+{
+ PixmapImagePtr image = new PixmapImage(0, 0, COLOR_DEPTH_DEFAULT, adaptor, pixmap);
+ return image;
+}
+
+Any PixmapImage::GetPixmap(PixmapAPI api)
+{
+ return mImpl->GetPixmap(api);
+}
+
+Any PixmapImage::GetDisplay()
+{
+ return mImpl->GetDisplay();
+}
+
+bool PixmapImage::GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const
+{
+ return mImpl->GetPixels( pixbuf, width, height, pixelFormat );
+}
+
+bool PixmapImage::EncodeToFile(const std::string& filename) const
+{
+ return mImpl->EncodeToFile(filename);
+}
+
+bool PixmapImage::GlExtensionCreate()
+{
+ return mImpl->GlExtensionCreate();
+}
+
+void PixmapImage::GlExtensionDestroy()
+{
+ mImpl->GlExtensionDestroy();
+}
+
+unsigned int PixmapImage::TargetTexture()
+{
+ return mImpl->TargetTexture();
+}
+
+void PixmapImage::PrepareTexture()
+{
+
+}
+
+unsigned int PixmapImage::GetWidth() const
+{
+ return mImpl->GetWidth();
+}
+
+unsigned int PixmapImage::GetHeight() const
+{
+ return mImpl->GetHeight();
+}
+
+Pixel::Format PixmapImage::GetPixelFormat() const
+{
+ return mImpl->GetPixelFormat();
+}
+
+PixmapImage::PixmapImage(unsigned int width, unsigned int height, ColorDepth depth, Adaptor& adaptor, Any pixmap)
+{
+ mImpl = Internal::Adaptor::PixmapImage::New( width, height, depth, adaptor, pixmap);
+}
+
+PixmapImage::~PixmapImage()
+{
+ delete mImpl;
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "render-surface-impl.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+RenderSurface::RenderSurface()
+{
+}
+
+RenderSurface::~RenderSurface()
+{
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_RENDER_SURFACE_H__
+#define __DALI_INTERNAL_RENDER_SURFACE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <render-surface.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/view-mode.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+
+class GlAbstraction;
+
+} // namespace Integration
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class EglInterface;
+
+/**
+ * This is the internal RenderSurface API
+ */
+class DALI_IMPORT_API RenderSurface : public Dali::RenderSurface
+{
+public:
+
+ enum SyncMode
+ {
+ SYNC_MODE_NONE, ///< Do not wait for RenderSync
+ SYNC_MODE_WAIT ///< Wait for RenderSync
+ };
+
+public:
+
+ /**
+ * Constructor
+ */
+ RenderSurface();
+
+ /**
+ * Destructor
+ */
+ virtual ~RenderSurface();
+
+public: // API
+
+ /**
+ * Initialize EGL, RenderSurface should create egl display and initialize
+ * @param egl implementation to use for the creation
+ */
+ virtual void InitializeEgl( EglInterface& egl ) = 0;
+
+ /**
+ * Creates EGL Surface
+ * @param egl implementation to use for the creation
+ */
+ virtual void CreateEglSurface( EglInterface& egl ) = 0;
+
+ /**
+ * Destroyes EGL Surface
+ * @param egl implementation to use for the destruction
+ */
+ virtual void DestroyEglSurface( EglInterface& egl ) = 0;
+
+ /**
+ * Replace the EGL Surface
+ * @param egl implementation to use for the creation
+ * @return true if context was lost
+ */
+ virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
+
+ /**
+ * Resizes the underlying surface.
+ * Only available for x window
+ */
+ virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
+
+ /**
+ * Get DPI
+ * @param dpiHorizontal set to the horizontal dpi
+ * @param dpiVertical set to the vertical dpi
+ */
+ virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) const = 0;
+
+ /**
+ * Call to map the surface (only works if surface is a window)
+ */
+ virtual void Map() = 0;
+
+ /**
+ * Transfers the ownership of a display
+ * @param newSurface to transfer
+ */
+ virtual void TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface ) = 0;
+
+ /**
+ * Consumes any possible events on the queue so that there is no leaking between frames
+ */
+ virtual void ConsumeEvents() = 0;
+
+ /**
+ * Set the stereoscopic 3D view mode
+ * @param[in] viewMode The new view mode
+ */
+ virtual void SetViewMode( ViewMode viewMode ) = 0;
+
+ /**
+ * Called after offscreen is posted to onscreen
+ */
+ virtual void RenderSync() = 0;
+
+ /**
+ * Invoked by render thread before Core::Render
+ * @param[in] egl The Egl interface
+ * @param[in] glAbstraction OpenGLES abstraction interface
+ * @return True if the operation is successful
+ */
+ virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) = 0;
+
+ /**
+ * Invoked by render thread after Core::Render
+ * @param[in] egl The Egl interface
+ * @param[in] glAbstraction OpenGLES abstraction interface
+ * @param[in] deltaTime Time (in microseconds) since PostRender was last called.
+ * @param[in] syncMode Wait for render sync flag.
+ * RenderSync will be skipped if this or SetSyncMode() is set to SYNC_MODE_NONE.
+ */
+ virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int deltaTime, SyncMode syncMode ) = 0;
+
+ /**
+ * Invoked by render thread when the thread should be stop
+ */
+ virtual void StopRender() = 0;
+
+ /**
+ * Set whether the surface should wait for RenderSync notifications
+ * @param[in] syncMode Wait for render sync flag. A member of SyncMode
+ */
+ virtual void SetSyncMode( SyncMode syncMode ) = 0;
+};
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_RENDER_SURFACE_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <render-surface.h>
+
+// INTERNAL INCLUDES
+#include <render-surface-impl.h>
+#include <pixmap-render-surface.h>
+#include <window-render-surface.h>
+
+namespace Dali
+{
+
+RenderSurface::RenderSurface()
+{
+}
+
+RenderSurface::~RenderSurface()
+{
+}
+
+RenderSurface* CreateDefaultSurface( RenderSurface::SurfaceType type, PositionSize positionSize, const std::string& name )
+{
+ // create a Ecore window by default
+ Any surface;
+ Any display;
+
+ Internal::Adaptor::ECore::RenderSurface* renderSurface(NULL);
+ if( RenderSurface::WINDOW == type )
+ {
+ renderSurface = new Internal::Adaptor::ECore::WindowRenderSurface( positionSize, surface, display, name );
+ }
+ else
+ {
+ renderSurface = new Internal::Adaptor::ECore::PixmapRenderSurface( positionSize, surface, display, name );
+ }
+
+ return renderSurface;
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ROTATION_OBSERVER_H__
+#define __DALI_INTERNAL_ROTATION_OBSERVER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+struct RotationEvent
+{
+ int angle; ///< one of 0, 90, 180, 270
+ int winResize; ///< true if the window should be resized
+ int width; ///< new window width
+ int height; ///< new window height
+};
+
+
+/**
+ * The RotationObserver can be overridden in order to listen to rotation events.
+ */
+class RotationObserver
+{
+public:
+
+ /**
+ * Deriving classes should override this to be notified when we receive a RotationPrepare event.
+ * @param[in] area The area that has been rotationd.
+ */
+ virtual void OnRotationPrepare( const RotationEvent& rotation ) = 0;
+
+ /**
+ * Deriving classes should override this to be notifed when a RotationRequest event is received
+ */
+ virtual void OnRotationRequest( ) = 0;
+
+protected:
+
+ /**
+ * Protected Constructor.
+ */
+ RotationObserver()
+ {
+ }
+
+ /**
+ * Protected virtual destructor.
+ */
+ virtual ~RotationObserver()
+ {
+ }
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ROTATION_OBSERVER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "server-connection.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+
+namespace
+{
+// Copied from ecore_evas_extn.c
+// procotol version - change this as needed
+const int MAJOR( 0x1011 );
+}
+
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+#if defined(DEBUG_ENABLED)
+extern Debug::Filter* gIndicatorLogFilter;
+#endif
+
+ServerConnection::~ServerConnection()
+{
+ CloseConnection();
+
+ if( mService.name != NULL )
+ {
+ eina_stringshare_del(mService.name);
+ }
+
+ for( Handlers::iterator iter = mIpcHandlers.begin(); iter != mIpcHandlers.end(); ++iter )
+ {
+ ecore_event_handler_del(*iter);
+ }
+ mIpcHandlers.clear();
+}
+
+bool ServerConnection::IsConnected()
+{
+ return mConnected;
+}
+
+void ServerConnection::OnDisconnect()
+{
+ mConnected = false;
+ mIpcServer = NULL;
+ ecore_ipc_shutdown();
+ if( mObserver )
+ {
+ mObserver->ConnectionClosed();
+ }
+}
+
+bool ServerConnection::SendEvent( int event, const void *data, int size )
+{
+ return SendEvent(event, 0, 0, data, size);
+}
+
+bool ServerConnection::SendEvent( int event, int ref, int ref_to, const void *data, int size )
+{
+ if( mIpcServer != NULL && ecore_ipc_server_send(mIpcServer, MAJOR, event, ref, ref_to, 0, data, size) )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+Eina_Bool ServerConnection::IpcServerAdd( void *data, int /*type*/, void *event )
+{
+ DALI_LOG_INFO(gIndicatorLogFilter, Debug::General, "ServerConnection: IpcServerAdd\n" );
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+Eina_Bool ServerConnection::IpcServerDel( void *data, int /*type*/, void *event )
+{
+ DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "ServerConnection: IpcServerDel\n" );
+
+ Ecore_Ipc_Event_Server_Del *e = static_cast<Ecore_Ipc_Event_Server_Del *>( event );
+ ServerConnection* connection = static_cast<ServerConnection*>( data );
+
+ if( connection != NULL )
+ {
+ if( connection->mIpcServer == e->server)
+ {
+ // No longer have a server connection
+ connection->OnDisconnect();
+ }
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+Eina_Bool ServerConnection::IpcServerData( void *data, int /*type*/, void *event )
+{
+ DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "ServerConnection: IpcServerData\n" );
+
+ Ecore_Ipc_Event_Server_Data *e = static_cast<Ecore_Ipc_Event_Server_Data *>( event );
+ ServerConnection* connection = static_cast<ServerConnection*>( data );
+
+ if( connection != NULL )
+ {
+ if( connection != ecore_ipc_server_data_get( e->server ) )
+ {
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ if( e->major != MAJOR )
+ {
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ if( connection->mObserver )
+ {
+ connection->mObserver->DataReceived( event );
+ }
+ }
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+void ServerConnection::CloseConnection()
+{
+ if( mConnected )
+ {
+ DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "ServerConnection: CloseConnection\n" );
+
+ if( mIpcServer )
+ {
+ ecore_ipc_server_del( mIpcServer );
+ mIpcServer = NULL;
+ }
+
+ ecore_ipc_shutdown();
+ mConnected = false;
+ }
+}
+
+} // Adaptor
+} // Internal
+} // Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_CONNECTION_H_
+#define __DALI_INTERNAL_ADAPTOR_CONNECTION_H_
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+#include <Ecore_Ipc.h>
+
+#include <dali/public-api/common/vector-wrapper.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+/**
+ * Makes a connection to a given service as a client
+ */
+class ServerConnection
+{
+public:
+ /**
+ * Observes the connection for data and connection closure
+ */
+ class Observer
+ {
+ public:
+ /**
+ * Inform that data has been received on the connection
+ * @param[in] event The event that has been received
+ */
+ virtual void DataReceived(void* event) = 0;
+
+ /**
+ * Inform the observer that the connection has closed
+ */
+ virtual void ConnectionClosed() = 0;
+ };
+
+public:
+ /**
+ * Constructor
+ * @param[in] serviceName The name of the service
+ * @param[in] serviceNumber The number of the service
+ * @param[in] isSystem Whether to connect as local user or system user
+ * @param[in] observer The connection observer
+ */
+ ServerConnection(const char *serviceName, int serviceNumber, bool isSystem, Observer* observer);
+
+ /**
+ * Destructor
+ */
+ ~ServerConnection();
+
+ /**
+ * Test if the connection is still alive
+ * @return True if the connection is still alive
+ */
+ bool IsConnected();
+
+ /**
+ * Disconnect from the server. Will trigger ConnectionClosed() observer callback
+ */
+ void OnDisconnect();
+
+ /**
+ * Send an event to the server.
+ * @param[in] event Event id
+ * @param[in] data Pointer to the event data
+ * @param[in] size Size of the event data
+ * @return whether the event is sent successfully or not
+ */
+ bool SendEvent( int event, const void *data, int size );
+
+ /**
+ * Send an event to the server.
+ * @param[in] event Event id
+ * @param[in] ref Message Reference number
+ * @param[in] refTo Reference number of the message this refers to
+ * @param[in] data Pointer to the event data
+ * @param[in] size Size of the event data
+ * @return whether the event is sent successfully or not
+ */
+ bool SendEvent( int event, int ref, int refTo, const void *data, int size );
+
+private: // Class callbacks
+ /**
+ * Callback when server added
+ */
+ static Eina_Bool IpcServerAdd(void *data, int type, void *event);
+
+ /**
+ * Callback when server deleted
+ */
+ static Eina_Bool IpcServerDel(void *data, int type, void *event);
+
+ /**
+ * Callback when data available from server
+ */
+ static Eina_Bool IpcServerData(void *data, int type, void *event);
+
+private:
+ void CloseConnection();
+
+private:
+ typedef std::vector<Ecore_Event_Handler *> Handlers;
+
+ struct Service
+ {
+ const char *name;
+ int num;
+ bool isSystem;
+ };
+
+ Service mService;
+ bool mConnected;
+ Observer* mObserver;
+ Ecore_Ipc_Server* mIpcServer;
+ Handlers mIpcHandlers;
+};
+
+} // Adaptor
+} // Internal
+} // Dali
+
+#endif // __DALI_INTERNAL_ADAPTOR_CONNECTION_H_
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "shared-file.h"
+
+// EXTERNAL INCLUDES
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/file.h>
+#include <sys/mman.h>
+
+#include <cstring>
+
+#include <Ecore.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+SharedFile* SharedFile::New(const char* filename, int size, bool isSystem)
+{
+ SharedFile *sf = NULL;
+
+ sf = new SharedFile;
+
+ bool opened = sf->OpenFile( filename, size, isSystem );
+ if( !opened )
+ {
+ delete sf;
+ sf = NULL;
+ }
+ return sf;
+}
+
+SharedFile::SharedFile()
+: mFileDescriptor(-1),
+ mSize(0),
+ mAddress(NULL),
+ mFilename()
+{
+}
+
+SharedFile::~SharedFile()
+{
+ Close();
+}
+
+void SharedFile::Close()
+{
+ if( mAddress != NULL )
+ {
+ munmap( mAddress, mSize );
+ mAddress = NULL;
+ }
+
+ if( mFileDescriptor >= 0 )
+ {
+ close( mFileDescriptor );
+ mFileDescriptor = -1;
+ }
+}
+
+unsigned char* SharedFile::GetAddress()
+{
+ return static_cast<unsigned char *>( mAddress );
+}
+
+bool SharedFile::OpenFile(const char* filename, int size, bool isSystem)
+{
+ bool opened = false;
+ mode_t mode;
+
+ mode = S_IRUSR | S_IWUSR;
+ if( isSystem )
+ {
+ mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
+ }
+
+ mFileDescriptor = shm_open( filename, O_RDWR, mode );
+
+ if( mFileDescriptor >= 0 )
+ {
+ mFilename = filename;
+
+ mSize = size;
+ mAddress = mmap( NULL, mSize, PROT_READ | PROT_WRITE, MAP_SHARED, mFileDescriptor, 0 );
+
+ if( mAddress != MAP_FAILED )
+ {
+ opened = true;
+ }
+ }
+ return opened;
+}
+
+} // Adaptor
+} // Internal
+} // Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_SHARED_FILE_H__
+#define __DALI_INTERNAL_ADAPTOR_SHARED_FILE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+class SharedFile
+{
+public:
+ /**
+ * Open an existing shared file for read/write
+ * @return The shared file, or NULL if a file could not be opened and mapped.
+ */
+ static SharedFile* New( const char* filename, int size, bool isSystem );
+
+ /**
+ * Constructor
+ */
+ SharedFile();
+
+ /**
+ * Destructor
+ */
+ virtual ~SharedFile();
+
+ /**
+ * Opens a file for read/write
+ * @return true if opened, false on error.
+ */
+ bool OpenFile( const char* filename, int size, bool isSystem );
+
+ /**
+ * Close the shared file
+ */
+ void Close();
+
+ /**
+ * Get the memory address of the shared file
+ * @return the memory address
+ */
+ unsigned char* GetAddress();
+
+private:
+ int mFileDescriptor;
+ int mSize;
+ void* mAddress;
+ std::string mFilename;
+};
+
+} // Adaptor
+} // Internal
+} // Dali
+
+#endif // __DALI_INTERNAL_ADAPTOR_SHARED_FILE_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <sound-player-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <adaptor-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace // unnamed namespace
+{
+
+// Type Registration
+Dali::BaseHandle Create()
+{
+ return SoundPlayer::Get();
+}
+
+Dali::TypeRegistration SOUND_PLAYER_TYPE( typeid(Dali::SoundPlayer), typeid(Dali::BaseHandle), Create );
+
+Dali::SignalConnectorType SIGNAL_CONNECTOR_1( SOUND_PLAYER_TYPE, Dali::SoundPlayer::SIGNAL_SOUND_PLAY_FINISHED, Dali::Internal::Adaptor::SoundPlayer::DoConnectSignal );
+
+} // unnamed namespace
+
+Dali::SoundPlayer SoundPlayer::New()
+{
+ Dali::SoundPlayer player = Dali::SoundPlayer( new SoundPlayer() );
+ return player;
+}
+
+Dali::SoundPlayer SoundPlayer::Get()
+{
+ Dali::SoundPlayer player;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::SoundPlayer ) );
+ if ( handle )
+ {
+ // If so, downcast the handle
+ player = Dali::SoundPlayer( dynamic_cast< SoundPlayer* >( handle.GetObjectPtr() ) );
+ }
+ else
+ {
+ Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
+ player = Dali::SoundPlayer( New() );
+ adaptorImpl.RegisterSingleton( typeid( player ), player );
+ }
+ }
+
+ return player;
+}
+
+int SoundPlayer::PlaySound( const std::string fileName )
+{
+ return mPlugin.PlaySound( fileName );
+}
+
+void SoundPlayer::Stop( int handle )
+{
+ mPlugin.StopSound( handle );
+}
+
+SoundPlayer::SoundPlayFinishedSignalV2& SoundPlayer::SoundPlayFinishedSignal()
+{
+ return mSoundPlayFinishedSignalV2;
+}
+
+bool SoundPlayer::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+{
+ bool connected( true );
+ SoundPlayer* player = dynamic_cast<SoundPlayer*>( object );
+
+ if( player &&
+ Dali::SoundPlayer::SIGNAL_SOUND_PLAY_FINISHED == signalName )
+ {
+ player->SoundPlayFinishedSignal().Connect( tracker, functor );
+ }
+ else
+ {
+ // signalName does not match any signal
+ connected = false;
+ }
+
+ return connected;
+}
+
+SoundPlayer::SoundPlayer()
+: mPlugin( FeedbackPluginProxy::DEFAULT_OBJECT_NAME )
+{
+}
+
+SoundPlayer::~SoundPlayer()
+{
+}
+
+void SoundPlayer::EmitSoundPlayFinishedSignal()
+{
+ // Emit SoundPlayFinished signal
+
+ if ( !mSoundPlayFinishedSignalV2.Empty() )
+ {
+ Dali::SoundPlayer handle( this );
+ mSoundPlayFinishedSignalV2.Emit( handle );
+ }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_SOUND_PLAYER_H__
+#define __DALI_INTERNAL_SOUND_PLAYER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <sound-player.h>
+#include <feedback/feedback-plugin-proxy.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Plays haptic effects.
+ */
+class SoundPlayer : public Dali::BaseObject
+{
+
+public:
+
+ typedef Dali::SoundPlayer::SoundPlayFinishedSignalV2 SoundPlayFinishedSignalV2;
+
+ /**
+ * Create a SoundPlayer.
+ * @return A newly created SoundPlayer.
+ */
+ static Dali::SoundPlayer New();
+
+ /**
+ * Retrieve a handle to the SoundPlayer. This creates an instance if none has been created.
+ * @return A handle to the SoundPlayer.
+ */
+ static Dali::SoundPlayer Get();
+
+ /**
+ * @copydoc Dali::SoundPlayer::PlaySound()
+ */
+ int PlaySound(const std::string fileName);
+
+ /**
+ * @copydoc Dali::SoundPlayer::Stop()
+ */
+ void Stop(int handle);
+
+ /**
+ * @copydoc Dali::SoundPlayer::SoundPlayFinishedSignal()
+ */
+ SoundPlayFinishedSignalV2& SoundPlayFinishedSignal();
+
+ /**
+ * Connects a callback function with the object's signals.
+ * @param[in] object The object providing the signal.
+ * @param[in] tracker Used to disconnect the signal.
+ * @param[in] signalName The signal to connect to.
+ * @param[in] functor A newly allocated FunctorDelegate.
+ * @return True if the signal was connected.
+ * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+ */
+ static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+
+private:
+
+ /**
+ * Private Constructor; see also soundPlayer::New()
+ * @param[in] soundPlayer The public sound player class
+ */
+ SoundPlayer();
+
+ /**
+ * Destructor
+ */
+ virtual ~SoundPlayer();
+
+ /**
+ * Emits the SoundPlayFinished signal.
+ */
+ void EmitSoundPlayFinishedSignal();
+
+ // Undefined
+ SoundPlayer(const SoundPlayer&);
+
+ // Undefined
+ SoundPlayer& operator=(SoundPlayer&);
+
+private:
+
+ FeedbackPluginProxy mPlugin;
+ SoundPlayFinishedSignalV2 mSoundPlayFinishedSignalV2;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+
+// Helpers for public-api forwarding methods
+
+inline Internal::Adaptor::SoundPlayer& GetImplementation(Dali::SoundPlayer& player)
+{
+ DALI_ASSERT_ALWAYS( player && "SoundPlayer handle is empty" );
+
+ BaseObject& handle = player.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::SoundPlayer&>(handle);
+}
+
+inline const Internal::Adaptor::SoundPlayer& GetImplementation(const Dali::SoundPlayer& player)
+{
+ DALI_ASSERT_ALWAYS( player && "SoundPlayer handle is empty" );
+
+ const BaseObject& handle = player.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::SoundPlayer&>(handle);
+}
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_SOUND_PLAYER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <sound-player.h>
+
+// INTERNAL INCLUDES
+#include <sound-player-impl.h>
+
+namespace Dali
+{
+
+const char* const SoundPlayer::SIGNAL_SOUND_PLAY_FINISHED = "sound-play-finished";
+
+SoundPlayer::SoundPlayer()
+{
+}
+
+SoundPlayer SoundPlayer::Get()
+{
+ return Internal::Adaptor::SoundPlayer::Get();
+}
+
+SoundPlayer::~SoundPlayer()
+{
+}
+
+int SoundPlayer::PlaySound(const std::string fileName)
+{
+ return GetImplementation(*this).PlaySound(fileName);
+}
+
+void SoundPlayer::Stop(int handle)
+{
+ GetImplementation(*this).Stop(handle);
+}
+
+SoundPlayer::SoundPlayFinishedSignalV2& SoundPlayer::SoundPlayFinishedSignal()
+{
+ return GetImplementation(*this).SoundPlayFinishedSignal();
+}
+
+SoundPlayer::SoundPlayer( Internal::Adaptor::SoundPlayer* player )
+: BaseHandle( player )
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "style-monitor-impl.h"
+
+// EXTERNAL INCLUDES
+#include <vconf.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+#include <adaptor-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+BaseHandle Create()
+{
+ BaseHandle handle( StyleMonitor::Get() );
+
+ if ( !handle && Adaptor::IsAvailable() )
+ {
+ Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
+ Dali::StyleMonitor styleMonitor = Dali::StyleMonitor( new StyleMonitor( adaptorImpl.GetPlatformAbstraction() ) );
+ adaptorImpl.RegisterSingleton( typeid( styleMonitor ), styleMonitor );
+ handle = styleMonitor;
+ }
+
+ return handle;
+}
+TypeRegistration STYLE_MONITOR_TYPE( typeid(Dali::StyleMonitor), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
+
+} // unnamed namespace
+
+Dali::StyleMonitor StyleMonitor::Get()
+{
+ Dali::StyleMonitor styleMonitor;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::StyleMonitor ) );
+ if(handle)
+ {
+ // If so, downcast the handle
+ styleMonitor = Dali::StyleMonitor( dynamic_cast< StyleMonitor* >( handle.GetObjectPtr() ) );
+ }
+ }
+
+ return styleMonitor;
+}
+
+StyleMonitor::StyleMonitor(Integration::PlatformAbstraction& platformAbstraction)
+: mPlatformAbstraction(platformAbstraction)
+{
+}
+
+StyleMonitor::~StyleMonitor()
+{
+}
+
+void StyleMonitor::StyleChanged(StyleChange styleChange)
+{
+ if (styleChange.defaultFontChange || styleChange.defaultFontSizeChange)
+ {
+ mPlatformAbstraction.UpdateDefaultsFromDevice();
+ }
+
+ EmitStyleChangeSignal(styleChange);
+}
+
+std::string StyleMonitor::GetDefaultFontFamily() const
+{
+ return mPlatformAbstraction.GetDefaultFontFamily();
+}
+
+float StyleMonitor::GetDefaultFontSize() const
+{
+ return mPlatformAbstraction.GetDefaultFontSize();
+}
+
+const std::string& StyleMonitor::GetTheme() const
+{
+ return mUserDefinedThemeFilePath;
+}
+
+void StyleMonitor::SetTheme(const std::string& path)
+{
+ StyleChange styleChange;
+ styleChange.themeChange = true;
+ styleChange.themeFilePath = path;
+ mUserDefinedThemeFilePath = path;
+
+ EmitStyleChangeSignal(styleChange);
+}
+
+Dali::StyleMonitor::StyleChangeSignalV2& StyleMonitor::StyleChangeSignal()
+{
+ return mStyleChangeSignalV2;
+}
+
+void StyleMonitor::EmitStyleChangeSignal(StyleChange styleChange)
+{
+ if( !mStyleChangeSignalV2.Empty() )
+ {
+ Dali::StyleMonitor handle( this );
+ mStyleChangeSignalV2.Emit( handle, styleChange );
+ }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_STYLE_MONITOR_H__
+#define __DALI_INTERNAL_STYLE_MONITOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/object/base-object.h>
+#include <style-monitor.h>
+#include <dali/integration-api/platform-abstraction.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * This holds the platform's style information.
+ * It provides a signal when any aspect of the default style changes on the device.
+ */
+class StyleMonitor : public BaseObject
+{
+public:
+
+ // Creation & Destruction
+
+ /**
+ * Constructor.
+ * @param[in] platformAbstraction The platform abstraction.
+ */
+ StyleMonitor(Integration::PlatformAbstraction& platformAbstraction);
+
+ /**
+ * Retrieve the initialized instance of the StyleMonitor.
+ * @return Handle to StyleMonitor.
+ */
+ static Dali::StyleMonitor Get();
+
+ // Style Change Notifications
+
+ /**
+ * Informs the Style Monitor that the style has changed.
+ * @param[in] styleChange The details of the change.
+ */
+ void StyleChanged(StyleChange styleChange);
+
+ // Style Information
+
+ /**
+ * @copydoc Dali::StyleMonitor::GetDefaultFontFamily() const
+ */
+ std::string GetDefaultFontFamily() const;
+
+ /**
+ * @copydoc Dali::StyleMonitor::GetDefaultFontSize() const
+ */
+ float GetDefaultFontSize() const;
+
+ /**
+ * @copydoc Dali::StyleMonitor::GetTheme() const
+ */
+ const std::string& GetTheme() const;
+
+ /**
+ * @copydoc Dali::StyleMonitor::SetTheme()
+ */
+ void SetTheme(const std::string& themeFilePath);
+
+ // Signals
+
+ /**
+ * @copydoc Dali::StyleMonitor::StyleChangeSignal()
+ */
+ Dali::StyleMonitor::StyleChangeSignalV2& StyleChangeSignal();
+
+protected:
+
+ /**
+ * Virtual Destructor.
+ */
+ virtual ~StyleMonitor();
+
+private:
+
+ /**
+ * Emit the style change signal.
+ * @param[in] styleChange The details of the style change
+ */
+ inline void EmitStyleChangeSignal(StyleChange styleChange);
+
+private:
+
+ Dali::StyleMonitor::StyleChangeSignalV2 mStyleChangeSignalV2; ///< Emitted when the style changes
+
+ Integration::PlatformAbstraction& mPlatformAbstraction; ///< Reference to the PlatformAbstraction (for retrieving defaults)
+ std::string mUserDefinedThemeFilePath;///< String containing the user defined theme file path
+
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+// Additional Helpers for public-api forwarding methods
+
+inline Internal::Adaptor::StyleMonitor& GetImplementation(Dali::StyleMonitor& monitor)
+{
+ DALI_ASSERT_ALWAYS(monitor && "Monitor handle is empty");
+ BaseObject& handle = monitor.GetBaseObject();
+ return static_cast<Internal::Adaptor::StyleMonitor&>(handle);
+}
+
+inline const Internal::Adaptor::StyleMonitor& GetImplementation(const Dali::StyleMonitor& monitor)
+{
+ DALI_ASSERT_ALWAYS(monitor && "Monitor handle is empty");
+ const BaseObject& handle = monitor.GetBaseObject();
+ return static_cast<const Internal::Adaptor::StyleMonitor&>(handle);
+}
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_STYLE_MONITOR_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <style-monitor.h>
+
+// INTERNAL INCLUDES
+#include <style-monitor-impl.h>
+
+namespace Dali
+{
+
+StyleMonitor::StyleMonitor()
+{
+}
+
+StyleMonitor::StyleMonitor(const StyleMonitor& monitor)
+: BaseHandle(monitor)
+{
+}
+
+StyleMonitor StyleMonitor::StyleMonitor::Get()
+{
+ return Internal::Adaptor::StyleMonitor::Get();
+}
+
+StyleMonitor::~StyleMonitor()
+{
+}
+
+std::string StyleMonitor::GetDefaultFontFamily() const
+{
+ return GetImplementation(*this).GetDefaultFontFamily();
+}
+
+float StyleMonitor::GetDefaultFontSize() const
+{
+ return GetImplementation(*this).GetDefaultFontSize();
+}
+
+const std::string& StyleMonitor::GetTheme() const
+{
+ return GetImplementation(*this).GetTheme();
+}
+
+void StyleMonitor::SetTheme(const std::string& themFilePath)
+{
+ return GetImplementation(*this).SetTheme(themFilePath);
+}
+
+StyleMonitor::StyleChangeSignalV2& StyleMonitor::StyleChangeSignal()
+{
+ return GetImplementation(*this).StyleChangeSignal();
+}
+
+StyleMonitor& StyleMonitor::operator=(const StyleMonitor& monitor)
+{
+ if( *this != monitor )
+ {
+ BaseHandle::operator=(monitor);
+ }
+ return *this;
+}
+
+StyleMonitor::StyleMonitor(Internal::Adaptor::StyleMonitor* internal)
+: BaseHandle(internal)
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <system_settings.h>
+#include <Elementary.h>
+
+// INTERNAL INCLUDES
+#include "system-settings.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+int GetLongPressTime( int defaultTime )
+{
+ return defaultTime;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_SYSTEM_SETTINGS_H___
+#define __DALI_INTERNAL_SYSTEM_SETTINGS_H___
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+// Get SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY from system setting if available
+int GetLongPressTime( int defaultTime );
+
+// Get ELM_ACCESS_ACTION_OVER from Elementary if available
+int GetElmAccessActionOver();
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_SYSTEM_SETTINGS_H___
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "tilt-sensor-impl.h"
+
+// EXTERNAL INCLUDES
+#include <cmath>
+#include <sensor.h>
+
+#include <dali/public-api/object/type-registry.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <adaptor-impl.h>
+
+#ifdef __arm__
+#define SENSOR_ENABLED
+#endif
+
+namespace // unnamed namespace
+{
+
+const int NUMBER_OF_SAMPLES = 10;
+
+const float MAX_ACCELEROMETER_XY_VALUE = 9.8f;
+
+// Type Registration
+Dali::BaseHandle Create()
+{
+ return Dali::Internal::Adaptor::TiltSensor::Get();
+}
+
+Dali::TypeRegistration typeRegistration( typeid(Dali::TiltSensor), typeid(Dali::BaseHandle), Create );
+
+Dali::SignalConnectorType signalConnector1( typeRegistration, Dali::TiltSensor::SIGNAL_TILTED, Dali::Internal::Adaptor::TiltSensor::DoConnectSignal );
+
+} // unnamed namespace
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+Dali::TiltSensor TiltSensor::New()
+{
+ Dali::TiltSensor sensor = Dali::TiltSensor(new TiltSensor());
+
+ return sensor;
+}
+
+Dali::TiltSensor TiltSensor::Get()
+{
+ Dali::TiltSensor sensor;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ // Check whether the keyboard focus manager is already created
+ Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::TiltSensor ) );
+ if(handle)
+ {
+ // If so, downcast the handle of singleton to keyboard focus manager
+ sensor = Dali::TiltSensor( dynamic_cast< TiltSensor* >( handle.GetObjectPtr() ) );
+ }
+ else
+ {
+ // Create a singleton instance
+ Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
+ sensor = TiltSensor::New();
+ adaptorImpl.RegisterSingleton( typeid( sensor ), sensor );
+ handle = sensor;
+ }
+ }
+
+ return sensor;
+}
+
+TiltSensor::~TiltSensor()
+{
+ Disable();
+}
+
+bool TiltSensor::Enable()
+{
+ // Make sure sensor API is responding
+ bool success = Update();
+
+ if ( success )
+ {
+ if ( !mTimer )
+ {
+ mTimer = Dali::Timer::New( 1000.0f / mFrequencyHertz );
+ mTimer.TickSignal().Connect( mTimerSlot, &TiltSensor::Update );
+ }
+
+ if ( mTimer &&
+ !mTimer.IsRunning() )
+ {
+ mTimer.Start();
+ }
+ }
+
+ return success;
+}
+
+void TiltSensor::Disable()
+{
+ if ( mTimer )
+ {
+ mTimer.Stop();
+ mTimer.Reset();
+ }
+}
+
+bool TiltSensor::IsEnabled() const
+{
+ return ( mTimer && mTimer.IsRunning() );
+}
+
+float TiltSensor::GetRoll() const
+{
+ return mRoll;
+}
+
+float TiltSensor::GetPitch() const
+{
+ return mPitch;
+}
+
+Quaternion TiltSensor::GetRotation() const
+{
+ return mRotation;
+}
+
+TiltSensor::TiltedSignalV2& TiltSensor::TiltedSignal()
+{
+ return mTiltedSignalV2;
+}
+
+void TiltSensor::SetUpdateFrequency( float frequencyHertz )
+{
+ DALI_ASSERT_ALWAYS( frequencyHertz > 0.0f && "Frequency must have a positive value" );
+
+ if ( fabsf(mFrequencyHertz - frequencyHertz) >= GetRangedEpsilon(mFrequencyHertz, frequencyHertz) )
+ {
+ mFrequencyHertz = frequencyHertz;
+
+ if ( mTimer )
+ {
+ mTimer.SetInterval( 1000.0f / mFrequencyHertz );
+ }
+ }
+}
+
+float TiltSensor::GetUpdateFrequency() const
+{
+ return mFrequencyHertz;
+}
+
+void TiltSensor::SetRotationThreshold(Radian rotationThreshold)
+{
+ mRotationThreshold = rotationThreshold;
+}
+
+Radian TiltSensor::GetRotationThreshold() const
+{
+ return mRotationThreshold;
+}
+
+bool TiltSensor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+{
+ bool connected( true );
+ TiltSensor* sensor = dynamic_cast<TiltSensor*>( object );
+
+ if( sensor &&
+ Dali::TiltSensor::SIGNAL_TILTED == signalName )
+ {
+ sensor->TiltedSignal().Connect( tracker, functor );
+ }
+ else
+ {
+ // signalName does not match any signal
+ connected = false;
+ }
+
+ return connected;
+}
+
+TiltSensor::TiltSensor()
+: mFrequencyHertz( Dali::TiltSensor::DEFAULT_UPDATE_FREQUENCY ),
+ mTimerSlot( this ),
+ mSensorFrameworkHandle( -1 ),
+ mRoll( 0.0f ),
+ mPitch( 0.0f ),
+ mRotation( 0.0f, Vector3::YAXIS ),
+ mRotationThreshold( 0.0f )
+{
+ mRollValues.resize( NUMBER_OF_SAMPLES, 0.0f );
+ mPitchValues.resize( NUMBER_OF_SAMPLES, 0.0f );
+}
+
+bool TiltSensor::Update()
+{
+ float newRoll = 0.0f;
+ float newPitch = 0.0f;
+ Quaternion newRotation;
+#ifdef SENSOR_ENABLED
+
+ // Read accelerometer data
+
+ mSensorFrameworkHandle = sf_connect( ACCELEROMETER_SENSOR );
+ if ( mSensorFrameworkHandle < 0 )
+ {
+ DALI_LOG_ERROR( "Failed to connect to sensor framework" );
+ return false;
+ }
+
+ if ( sf_start(mSensorFrameworkHandle, 0) < 0 )
+ {
+ DALI_LOG_ERROR( "Failed to start sensor" );
+ sf_disconnect(mSensorFrameworkHandle);
+ return false;
+ }
+
+ sensor_data_t* base_data_values = (sensor_data_t*)malloc(sizeof(sensor_data_t));
+
+ int dataErr = sf_get_data(mSensorFrameworkHandle, ACCELEROMETER_BASE_DATA_SET, base_data_values);
+ if ( dataErr < 0 )
+ {
+ DALI_LOG_ERROR( "Failed to retrieve sensor data" );
+ free(base_data_values);
+ sf_stop(mSensorFrameworkHandle);
+ sf_disconnect(mSensorFrameworkHandle);
+ return false;
+ }
+
+ sf_stop(mSensorFrameworkHandle);
+ sf_disconnect(mSensorFrameworkHandle);
+
+ mRollValues.push_back( base_data_values->values[0] );
+ mRollValues.pop_front();
+
+ mPitchValues.push_back( base_data_values->values[1] );
+ mPitchValues.pop_front();
+
+ free(base_data_values);
+ base_data_values = NULL;
+
+ float averageRoll( 0.0f );
+ for ( std::deque<float>::const_iterator iter = mRollValues.begin(); mRollValues.end() != iter; ++iter )
+ {
+ averageRoll += *iter;
+ }
+ averageRoll /= mRollValues.size();
+
+ float averagePitch( 0.0f );
+ for ( std::deque<float>::const_iterator iter = mPitchValues.begin(); mPitchValues.end() != iter; ++iter )
+ {
+ averagePitch += *iter;
+ }
+ averagePitch /= mPitchValues.size();
+
+ newRoll = Clamp( float(averageRoll / MAX_ACCELEROMETER_XY_VALUE), -1.0f/*min*/, 1.0f/*max*/ );
+ newPitch = Clamp( float(averagePitch / MAX_ACCELEROMETER_XY_VALUE), -1.0f/*min*/, 1.0f/*max*/ );
+
+ newRotation = Quaternion( newRoll * Math::PI * -0.5f, Vector3::YAXIS ) *
+ Quaternion( newPitch * Math::PI * -0.5f, Vector3::XAXIS );
+#endif // SENSOR_ENABLED
+
+ Radian angle(Quaternion::AngleBetween(newRotation, mRotation));
+ // If the change in value is more than the threshold then emit tilted signal.
+ if( angle > mRotationThreshold )
+ {
+ mRoll = newRoll;
+ mPitch = newPitch;
+ mRotation = newRotation;
+
+ if ( !mTiltedSignalV2.Empty() )
+ {
+ Dali::TiltSensor handle( this );
+ mTiltedSignalV2.Emit( handle );
+ }
+ }
+
+ return true;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_TILT_SENSOR_H__
+#define __DALI_INTERNAL_ADAPTOR_TILT_SENSOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <deque>
+#include <dali/public-api/object/base-object.h>
+#include <timer.h>
+
+// INTERNAL INCLUDES
+#include <tilt-sensor.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * TiltSensor provides pitch & roll values when the device is tilted.
+ */
+class TiltSensor : public Dali::BaseObject
+{
+public:
+
+ typedef Dali::TiltSensor::TiltedSignalV2 TiltedSignalV2;
+
+ /**
+ * Create a TiltSensor.
+ * This should only be called once by the Adaptor class.
+ * @return A newly allocated tilt-sensor.
+ */
+ static Dali::TiltSensor New();
+
+ /**
+ * @copydoc Dali::TiltSensor::Get()
+ */
+ static Dali::TiltSensor Get();
+
+ /**
+ * @copydoc Dali::TiltSensor::Enable()
+ */
+ bool Enable();
+
+ /**
+ * @copydoc Dali::TiltSensor::Disable()
+ */
+ void Disable();
+
+ /**
+ * @copydoc Dali::TiltSensor::IsEnabled()
+ */
+ bool IsEnabled() const;
+
+ /**
+ * @copydoc Dali::TiltSensor::GetRoll()
+ */
+ float GetRoll() const;
+
+ /**
+ * @copydoc Dali::TiltSensor::GetPitch()
+ */
+ float GetPitch() const;
+
+ /**
+ * @copydoc Dali::TiltSensor::GetRotation()
+ */
+ Quaternion GetRotation() const;
+
+ /**
+ * @copydoc Dali::TiltSensor::TiltedSignal()
+ */
+ TiltedSignalV2& TiltedSignal();
+
+ /**
+ * @copydoc Dali::TiltSensor::SetUpdateFrequency()
+ */
+ void SetUpdateFrequency( float frequencyHertz );
+
+ /**
+ * @copydoc Dali::TiltSensor::GetUpdateFrequency()
+ */
+ float GetUpdateFrequency() const;
+
+ /**
+ * @copydoc Dali::TiltSensor::SetRotationThreshold()
+ */
+ void SetRotationThreshold(Radian rotationThreshold);
+
+ /**
+ * @copydoc Dali::TiltSensor::GetRotationThreshold()
+ */
+ Radian GetRotationThreshold() const;
+
+ /**
+ * Connects a callback function with the object's signals.
+ * @param[in] object The object providing the signal.
+ * @param[in] tracker Used to disconnect the signal.
+ * @param[in] signalName The signal to connect to.
+ * @param[in] functor A newly allocated FunctorDelegate.
+ * @return True if the signal was connected.
+ * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+ */
+ static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+
+private:
+
+ /**
+ * Private constructor; see also TiltSensor::New()
+ */
+ TiltSensor();
+
+ /**
+ * Destructor
+ */
+ virtual ~TiltSensor();
+
+ /**
+ * Timer callback to update the tilt values
+ */
+ bool Update();
+
+ // Undefined
+ TiltSensor(const TiltSensor&);
+
+ // Undefined
+ TiltSensor& operator=(TiltSensor&);
+
+private:
+
+ float mFrequencyHertz;
+ Dali::Timer mTimer;
+ SlotDelegate< TiltSensor > mTimerSlot;
+
+ int mSensorFrameworkHandle;
+
+ float mRoll;
+ float mPitch;
+ Quaternion mRotation;
+
+ Radian mRotationThreshold;
+
+ std::deque<float> mRollValues;
+ std::deque<float> mPitchValues;
+
+ TiltedSignalV2 mTiltedSignalV2;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Internal::Adaptor::TiltSensor& GetImplementation(Dali::TiltSensor& sensor)
+{
+ DALI_ASSERT_ALWAYS( sensor && "TiltSensor handle is empty" );
+
+ BaseObject& handle = sensor.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::TiltSensor&>(handle);
+}
+
+inline const Internal::Adaptor::TiltSensor& GetImplementation(const Dali::TiltSensor& sensor)
+{
+ DALI_ASSERT_ALWAYS( sensor && "TiltSensor handle is empty" );
+
+ const BaseObject& handle = sensor.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::TiltSensor&>(handle);
+}
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ADAPTOR_TILT_SENSOR_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "tilt-sensor.h"
+
+// INTERNAL INCLUDES
+#include <tilt-sensor-impl.h>
+#include <adaptor-impl.h>
+
+namespace Dali
+{
+
+const char* const TiltSensor::SIGNAL_TILTED = "tilted";
+
+const float TiltSensor::DEFAULT_UPDATE_FREQUENCY = 60.0f;
+
+TiltSensor::TiltSensor()
+{
+}
+
+TiltSensor TiltSensor::Get()
+{
+ return Internal::Adaptor::TiltSensor::Get();
+}
+
+TiltSensor::~TiltSensor()
+{
+}
+
+bool TiltSensor::Enable()
+{
+ return GetImplementation(*this).Enable();
+}
+
+void TiltSensor::Disable()
+{
+ GetImplementation(*this).Disable();
+}
+
+bool TiltSensor::IsEnabled() const
+{
+ return GetImplementation(*this).IsEnabled();
+}
+
+float TiltSensor::GetRoll() const
+{
+ return GetImplementation(*this).GetRoll();
+}
+
+float TiltSensor::GetPitch() const
+{
+ return GetImplementation(*this).GetPitch();
+}
+
+Quaternion TiltSensor::GetRotation() const
+{
+ return GetImplementation(*this).GetRotation();
+}
+
+TiltSensor::TiltedSignalV2& TiltSensor::TiltedSignal()
+{
+ return GetImplementation(*this).TiltedSignal();
+}
+
+void TiltSensor::SetUpdateFrequency( float frequencyHertz )
+{
+ GetImplementation(*this).SetUpdateFrequency( frequencyHertz );
+}
+
+float TiltSensor::GetUpdateFrequency() const
+{
+ return GetImplementation(*this).GetUpdateFrequency();
+}
+
+void TiltSensor::SetRotationThreshold(Radian rotationThreshold)
+{
+ GetImplementation(*this).SetRotationThreshold( rotationThreshold );
+}
+
+Radian TiltSensor::GetRotationThreshold() const
+{
+ return GetImplementation(*this).GetRotationThreshold();
+}
+
+TiltSensor::TiltSensor( Internal::Adaptor::TiltSensor* sensor )
+: BaseHandle( sensor )
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "timer-impl.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+// LOCAL STUFF
+namespace
+{
+Eina_Bool TimerSourceFunc (void *data)
+{
+ Timer* timer = static_cast<Timer*>(data);
+
+ bool keepRunning = timer->Tick();
+
+ return keepRunning ? EINA_TRUE : EINA_FALSE;
+}
+} // unnamed namespace
+
+/**
+ * Struct to hide away Ecore implementation details
+ */
+struct Timer::Impl
+{
+ Impl( unsigned int milliSec )
+ : mId(NULL),
+ mInterval(milliSec)
+ {
+ }
+
+ Ecore_Timer * mId;
+ unsigned int mInterval;
+};
+
+TimerPtr Timer::New( unsigned int milliSec )
+{
+ TimerPtr timer( new Timer( milliSec ) );
+ return timer;
+}
+
+Timer::Timer( unsigned int milliSec )
+: mImpl(new Impl(milliSec))
+{
+}
+
+Timer::~Timer()
+{
+ // stop timers
+ Stop();
+
+ delete mImpl;
+}
+
+void Timer::Start()
+{
+ if(mImpl->mId > 0)
+ {
+ Stop();
+ }
+ mImpl->mId = ecore_timer_add( (double)mImpl->mInterval/1000.0f, (Ecore_Task_Cb)TimerSourceFunc, this );
+}
+
+void Timer::Stop()
+{
+ if (mImpl->mId != NULL)
+ {
+ ecore_timer_del(mImpl->mId);
+ mImpl->mId = NULL;
+ }
+}
+
+void Timer::SetInterval( unsigned int interval )
+{
+ // stop existing timer
+ Stop();
+ mImpl->mInterval = interval;
+ // start new tick
+ Start();
+}
+
+unsigned int Timer::GetInterval() const
+{
+ return mImpl->mInterval;
+}
+
+bool Timer::Tick()
+{
+ // Guard against destruction during signal emission
+ Dali::Timer handle( this );
+
+ bool retVal( false );
+
+ // Override with new signal if used
+ if( !mTickSignal.Empty() )
+ {
+ retVal = mTickSignal.Emit();
+
+ // Timer stops if return value is false
+ if (retVal == false)
+ {
+ Stop();
+ }
+ else
+ {
+ retVal = true; // continue emission
+ }
+ }
+ else // no callbacks registered
+ {
+ // periodic timer is started but nobody listens, continue
+ retVal = true;
+ }
+
+ return retVal;
+}
+
+Dali::Timer::TimerSignalV2& Timer::TickSignal()
+{
+ return mTickSignal;
+}
+
+bool Timer::IsRunning() const
+{
+ return mImpl->mId != NULL;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_TIMER_H__
+#define __DALI_INTERNAL_TIMER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/object/base-object.h>
+#include <timer.h>
+
+// INTERNAL INCLUDES
+#include <base/interfaces/timer-interface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class Timer;
+
+typedef IntrusivePtr<Timer> TimerPtr;
+
+/**
+ * Implementation of the timer
+ */
+class Timer : public BaseObject, public TimerInterface
+{
+public:
+ static TimerPtr New( unsigned int milliSec );
+
+ /**
+ * Constructor
+ * @param[in] milliSec Interval in milliseconds.
+ */
+ Timer( unsigned int milliSec );
+
+ /**
+ * Destructor.
+ */
+ virtual ~Timer();
+
+public:
+
+ /**
+ * @copydoc Dali::Timer::Start()
+ */
+ virtual void Start();
+
+ /**
+ * @copydoc Dali::Timer::Stop()
+ */
+ virtual void Stop();
+
+ /**
+ * @copydoc Dali::Timer::SetInterval()
+ */
+ virtual void SetInterval( unsigned int interval );
+
+ /**
+ * @copydoc Dali::Timer::GetInterval()
+ */
+ virtual unsigned int GetInterval() const;
+
+ /**
+ * @copydoc Dali::Timer::IsRunning()
+ */
+ virtual bool IsRunning() const;
+
+ /**
+ * Tick
+ */
+ bool Tick();
+
+public: // Signals
+
+ Dali::Timer::TimerSignalV2& TickSignal();
+
+private: // Implementation
+
+ // not implemented
+ Timer( const Timer& );
+ Timer& operator=( const Timer& );
+
+private: // Data
+
+ Dali::Timer::TimerSignalV2 mTickSignal;
+
+ // To hide away implementation details
+ struct Impl;
+ Impl* mImpl;
+};
+
+inline Timer& GetImplementation(Dali::Timer& timer)
+{
+ DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
+
+ BaseObject& handle = timer.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::Timer&>(handle);
+}
+
+inline const Timer& GetImplementation(const Dali::Timer& timer)
+{
+ DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
+
+ const BaseObject& handle = timer.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::Timer&>(handle);
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_TIMER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <timer.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+
+// INTERNAL INCLUDES
+#include <timer-impl.h>
+
+namespace Dali
+{
+
+Timer::Timer()
+{
+}
+
+Timer Timer::New( unsigned int milliSec )
+{
+ Internal::Adaptor::TimerPtr internal = Internal::Adaptor::Timer::New( milliSec );
+ return Timer(internal.Get());
+}
+
+Timer::Timer( const Timer& timer )
+: BaseHandle(timer)
+{
+}
+
+Timer& Timer::operator=( const Timer& timer )
+{
+ // check self assignment
+ if( *this != timer )
+ {
+ BaseHandle::operator=(timer);
+ }
+ return *this;
+}
+
+Timer::~Timer()
+{
+}
+
+void Timer::Start()
+{
+ Internal::Adaptor::GetImplementation(*this).Start();
+}
+
+void Timer::Stop()
+{
+ Internal::Adaptor::GetImplementation(*this).Stop();
+}
+
+void Timer::SetInterval( unsigned int interval )
+{
+ Internal::Adaptor::GetImplementation(*this).SetInterval( interval );
+}
+
+unsigned int Timer::GetInterval() const
+{
+ return Internal::Adaptor::GetImplementation(*this).GetInterval();
+}
+
+bool Timer::IsRunning() const
+{
+ return Internal::Adaptor::GetImplementation(*this).IsRunning();
+}
+
+Timer::TimerSignalV2& Timer::TickSignal()
+{
+ return Internal::Adaptor::GetImplementation(*this).TickSignal();
+}
+
+Timer::Timer(Internal::Adaptor::Timer* timer)
+: BaseHandle(timer)
+{
+}
+
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "trigger-event-factory.h"
+
+// INTERNAL INCLUDES
+#include <trigger-event.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+TriggerEventInterface* TriggerEventFactory::CreateTriggerEvent( boost::function<void()> functor, TriggerEventInterface::Options options )
+{
+ return new TriggerEvent( functor, options );
+}
+
+void TriggerEventFactory::DestroyTriggerEvent( TriggerEventInterface* triggerEventInterface )
+{
+ TriggerEvent* triggerEvent( static_cast< TriggerEvent* >( triggerEventInterface) );
+ delete triggerEvent;
+}
+
+
+} // namespace Internal
+
+} // namespace Adaptor
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_TRIGGER_EVENT_FACTORY_H__
+#define __DALI_INTERNAL_ADAPTOR_TRIGGER_EVENT_FACTORY_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <base/interfaces/trigger-event-factory-interface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * @brief Trigger interface factory class
+ *
+ */
+class TriggerEventFactory : public TriggerEventFactoryInterface
+{
+
+public:
+
+ /**
+ * @brief Constructor
+ */
+ TriggerEventFactory()
+ {
+ }
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~TriggerEventFactory()
+ {
+ }
+
+ /**
+ * @copydoc TriggerEventFactoryInterface::CreateTriggerEvent
+ */
+ virtual TriggerEventInterface* CreateTriggerEvent( boost::function<void()> functor, TriggerEventInterface::Options options );
+
+
+ /**
+ * @copydoc TriggerEventFactoryInterface::DestroyTriggerEvent
+ */
+ virtual void DestroyTriggerEvent( TriggerEventInterface* triggerEventInterface );
+
+};
+
+} // namespace Internal
+
+} // namespace Adaptor
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ADAPTOR_TRIGGER_EVENT_FACTORY_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "trigger-event.h"
+
+// EXTERNAL INCLUDES
+#include <sys/eventfd.h>
+#include <boost/bind.hpp>
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+
+#include <file-descriptor-monitor.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+TriggerEvent::TriggerEvent( boost::function<void()> functor, TriggerEventInterface::Options options )
+: mFileDescriptorMonitor(NULL),
+ mFunctor(functor),
+ mFileDescriptor(-1),
+ mOptions( options )
+{
+ // Create accompanying file descriptor.
+ mFileDescriptor = eventfd(0, EFD_NONBLOCK);
+ if (mFileDescriptor >= 0)
+ {
+ // Now Monitor the created event file descriptor
+ mFileDescriptorMonitor = new FileDescriptorMonitor(mFileDescriptor, boost::bind(&TriggerEvent::Triggered, this));
+ }
+ else
+ {
+ DALI_LOG_ERROR("Unable to create TriggerEvent File descriptor\n");
+ }
+}
+
+TriggerEvent::~TriggerEvent()
+{
+ if (mFileDescriptorMonitor)
+ {
+ delete mFileDescriptorMonitor;
+ mFileDescriptorMonitor = NULL;
+ }
+
+ if (mFileDescriptor >= 0)
+ {
+ close(mFileDescriptor);
+ mFileDescriptor = 0;
+ }
+}
+
+void TriggerEvent::Trigger()
+{
+ if (mFileDescriptor >= 0)
+ {
+ // Increment event counter by 1.
+ // Writing to the file descriptor triggers the Dispatch() method in the other thread
+ // (if in multi-threaded environment).
+
+ uint64_t data = 1;
+ int size = write(mFileDescriptor, &data, sizeof(uint64_t));
+
+ if (size != sizeof(uint64_t))
+ {
+ DALI_LOG_ERROR("Unable to write to UpdateEvent File descriptor\n");
+ }
+ }
+ else
+ {
+ DALI_LOG_WARNING("Attempting to write to an invalid file descriptor\n");
+ }
+}
+
+void TriggerEvent::Triggered()
+{
+ // Reading from the file descriptor resets the event counter, we can ignore the count.
+ uint64_t receivedData;
+ size_t size;
+ size = read(mFileDescriptor, &receivedData, sizeof(uint64_t));
+ if (size != sizeof(uint64_t))
+ {
+ DALI_LOG_WARNING("Unable to read to UpdateEvent File descriptor\n");
+ }
+
+ // Call the connected boost function.
+ mFunctor();
+
+ //check if we should delete ourselves after the trigger
+ if( mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER )
+ {
+ delete this;
+ }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_TRIGGER_EVENT_H__
+#define __DALI_INTERNAL_TRIGGER_EVENT_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+#include <base/interfaces/trigger-event-interface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class FileDescriptorMonitor;
+
+/**
+ * The TriggerEvent class is used to send events between threads. For example, this can be used
+ * to wake up one thread from another thread.
+ *
+ * Typically, these should be created in the application thread.
+ *
+ * The observer will be informed whenever the event is triggered.
+ *
+ * The implementation of TriggerEvent uses an event file descriptor.
+ */
+class DALI_IMPORT_API TriggerEvent : public TriggerEventInterface
+{
+public:
+
+ /**
+ * Constructor
+ * Creates an event file descriptor and starts a GSource which reads from the file
+ * descriptor when there is data.
+ *
+ * @param[in] functor to call
+ * @param[in] options, trigger event options.
+ */
+ TriggerEvent( boost::function<void()> functor, TriggerEventInterface::Options options = TriggerEventInterface::NONE );
+
+ /**
+ * Destructor
+ */
+ ~TriggerEvent();
+
+public:
+
+ /**
+ * Triggers the event.
+ *
+ * This can be called from one thread in order to wake up another thread.
+ */
+ void Trigger();
+
+private:
+
+ /**
+ * Called when our event file descriptor has been written to.
+ */
+ void Triggered();
+
+private:
+
+ struct Source;
+
+private:
+
+ FileDescriptorMonitor* mFileDescriptorMonitor;
+ boost::function<void()> mFunctor; ///< Function object to call
+ int mFileDescriptor;
+ TriggerEventInterface::Options mOptions;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_TRIGGER_EVENT_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "tts-player-impl.h"
+
+// EXTERNAL INCLUDES
+#include <tts.h>
+#include <stdio.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace // unnamed namespace
+{
+// Type Registration
+Dali::BaseHandle Create()
+{
+ return Dali::TtsPlayer::Get() ;
+}
+
+Dali::TypeRegistration mType( typeid(Dali::TtsPlayer), typeid(Dali::BaseHandle), Create ) ;
+} // unnamed namespace
+
+#if defined(DEBUG_ENABLED)
+Debug::Filter* TtsPlayer::gLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_TTS_PLAYER");
+#endif
+
+Dali::TtsPlayer TtsPlayer::New(Dali::TtsPlayer::Mode mode)
+{
+ Dali::TtsPlayer player = Dali::TtsPlayer(new TtsPlayer(mode));
+
+ return player;
+}
+
+TtsPlayer::TtsPlayer(Dali::TtsPlayer::Mode mode)
+: mInitialized(false),
+ mUnplayedString(""),
+ mUtteranceId(0),
+ mTtsMode(mode)
+{
+ Initialize();
+}
+
+TtsPlayer::~TtsPlayer()
+{
+ // If it is playing, stop it
+ Stop();
+
+ // Unset the callback funtion for TTS state change
+ int retVal = tts_unset_state_changed_cb(mTtsHandle);
+ if( retVal != TTS_ERROR_NONE )
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+
+ // Destroy the TTS handle and disconnects the daemon
+ retVal = tts_destroy(mTtsHandle);
+ if( retVal != TTS_ERROR_NONE )
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+}
+
+void TtsPlayer::Initialize()
+{
+ // Create the TTS handle
+ int retVal = tts_create(&mTtsHandle);
+
+ if( retVal != TTS_ERROR_NONE )
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+ else
+ {
+ // Set the callback funtion for TTS state change
+ retVal = tts_set_state_changed_cb(mTtsHandle, &StateChangedCallback, this);
+ if( retVal != TTS_ERROR_NONE )
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+
+ // Check tts mode
+ tts_mode_e ttsMode = TTS_MODE_DEFAULT;
+ switch (mTtsMode)
+ {
+ case Dali::TtsPlayer::DEFAULT:
+ ttsMode = TTS_MODE_DEFAULT;
+ break;
+ case Dali::TtsPlayer::NOTIFICATION:
+ ttsMode = TTS_MODE_NOTIFICATION;
+ break;
+ case Dali::TtsPlayer::SCREEN_READER:
+ ttsMode = TTS_MODE_SCREEN_READER;
+ break;
+ default:
+ break;
+ }
+
+ // Set mode
+ retVal = tts_set_mode(mTtsHandle, ttsMode);
+ if(retVal != TTS_ERROR_NONE)
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+
+ // Connect the TTS daemon asynchronously
+ retVal = tts_prepare(mTtsHandle);
+ if(retVal != TTS_ERROR_NONE)
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+ }
+}
+
+void TtsPlayer::Play(const std::string& text)
+{
+ if(mInitialized)
+ {
+ Stop();
+
+ // Add text to the queue, and use normal speed, default language and default voice set by the user
+ int retVal = tts_add_text(mTtsHandle, text.c_str(), NULL, TTS_VOICE_TYPE_AUTO, TTS_SPEED_AUTO, &mUtteranceId);
+ if(retVal != TTS_ERROR_NONE)
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+ else
+ {
+ // Start synthesizing voice from text in the queue and play synthesized audio data
+ retVal = tts_play(mTtsHandle);
+ if(retVal != TTS_ERROR_NONE)
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+ }
+ }
+ else
+ {
+ mUnplayedString = text;
+ }
+}
+
+void TtsPlayer::Stop()
+{
+ if(mInitialized)
+ {
+ // Check the current TTS state
+ tts_state_e state;
+ int retVal = tts_get_state(mTtsHandle, &state);
+ if(retVal != TTS_ERROR_NONE)
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+ else if(state == TTS_STATE_PLAYING || state == TTS_STATE_PAUSED)
+ {
+ // If it is playing or paused, stop playing and clear the queue
+ retVal = tts_stop(mTtsHandle);
+ if( retVal != TTS_ERROR_NONE )
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+ }
+ }
+}
+
+void TtsPlayer::Pause()
+{
+ if(mInitialized)
+ {
+ // Check the current TTS state
+ tts_state_e state;
+ int retVal = tts_get_state(mTtsHandle, &state);
+ if(retVal != TTS_ERROR_NONE)
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+ else if(state == TTS_STATE_PLAYING)
+ {
+ // If the player is playing, pause it.
+ retVal = tts_pause(mTtsHandle);
+ if( retVal != TTS_ERROR_NONE )
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+ }
+ }
+}
+
+void TtsPlayer::Resume()
+{
+ if(mInitialized)
+ {
+ // Check the current TTS state
+ tts_state_e state;
+ int retVal = tts_get_state(mTtsHandle, &state);
+ if(retVal != TTS_ERROR_NONE)
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+ else if(state == TTS_STATE_PAUSED)
+ {
+ // If the player is paused, resume it.
+ retVal = tts_play(mTtsHandle);
+ if( retVal != TTS_ERROR_NONE )
+ {
+ LogErrorCode(static_cast<tts_error_e>(retVal));
+ }
+ }
+ }
+}
+
+void TtsPlayer::StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void *userData)
+{
+ TtsPlayer* obj = static_cast<TtsPlayer*>(userData);
+ if(!obj->mInitialized && current == TTS_STATE_READY)
+ {
+ obj->mInitialized = true;
+
+ // if there is queued text before initialization, play it
+ if(obj->mUnplayedString != "")
+ {
+ obj->Play(obj->mUnplayedString);
+ obj->mUnplayedString = "";
+ }
+ }
+}
+
+void TtsPlayer::LogErrorCode(tts_error_e reason)
+{
+ std::string error_string;
+
+ switch (reason)
+ {
+ case TTS_ERROR_NONE:
+ {
+ break;
+ }
+ case TTS_ERROR_OUT_OF_MEMORY:
+ {
+ error_string = "TTS: Out of Memory\n";
+ break;
+ }
+ case TTS_ERROR_IO_ERROR:
+ {
+ error_string = "TTS: I/O error\n";
+ break;
+ }
+ case TTS_ERROR_INVALID_PARAMETER:
+ {
+ error_string = "TTS: Invalid parameter\n";
+ break;
+ }
+ case TTS_ERROR_OUT_OF_NETWORK:
+ {
+ error_string = "TTS: Out of network\n";
+ break;
+ }
+ case TTS_ERROR_INVALID_STATE:
+ {
+ error_string = "TTS: Invalid state\n";
+ break;
+ }
+ case TTS_ERROR_INVALID_VOICE:
+ {
+ error_string = "TTS: Invalid voice\n";
+ break;
+ }
+ case TTS_ERROR_ENGINE_NOT_FOUND:
+ {
+ error_string = "TTS: No available engine\n";
+ break;
+ }
+ case TTS_ERROR_TIMED_OUT:
+ {
+ error_string = "TTS: No answer from the daemon\n";
+ break;
+ }
+ case TTS_ERROR_OPERATION_FAILED:
+ {
+ error_string = "TTS: Operation failed\n";
+ break;
+ }
+ default:
+ {
+ error_string = "Invalid TTS error code\n";
+ break;
+ }
+ }
+
+ if(reason != TTS_ERROR_NONE)
+ {
+ DALI_LOG_WARNING("[%s:%d] tts error : %s\n", __FUNCTION__, __LINE__, error_string.c_str());
+ }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_TTS_PLAYER_H__
+#define __DALI_INTERNAL_TTS_PLAYER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <tts.h>
+#include <string>
+
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/base-object.h>
+#include <tts-player.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Text-to-speech player
+ */
+class TtsPlayer : public Dali::BaseObject
+{
+
+public:
+
+ /**
+ * Create a TtsPlayer with the given mode.
+ * This should only be called once by the Adaptor class for each given mode.
+ * @param mode the mode of tts-player
+ * @return A newly created TtsPlayer.
+ */
+ static Dali::TtsPlayer New(Dali::TtsPlayer::Mode mode);
+
+ /**
+ * @copydoc TtsPlayer::Play()
+ */
+ void Play(const std::string& text);
+
+ /**
+ * @copydoc TtsPlayer::Stop()
+ */
+ void Stop();
+
+ /**
+ * @copydoc TtsPlayer::Pause()
+ */
+ void Pause();
+
+ /**
+ * @copydoc TtsPlayer::Resume()
+ */
+ void Resume();
+
+private:
+
+ /**
+ * Private Constructor; see also TtsPlayer::New()
+ * @param mode the mode of tts-player
+ */
+ TtsPlayer(Dali::TtsPlayer::Mode mode);
+
+ /**
+ * Destructor
+ */
+ virtual ~TtsPlayer();
+
+ /**
+ * Initializes the player.
+ */
+ void Initialize();
+
+ /**
+ * Logs the error code.
+ * @param[in] reason The error code
+ */
+ void LogErrorCode(tts_error_e reason);
+
+ /**
+ * Called when the state of TTS is changed.
+ *
+ * @param[in] tts The handle for TTS
+ * @param[in] previous A previous state
+ * @param[in] current A current state
+ * @param[in] userData The user data passed from the callback registration function.
+ */
+ static void StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void *userData);
+
+ // Undefined
+ TtsPlayer(const TtsPlayer&);
+
+ // Undefined
+ TtsPlayer& operator=(TtsPlayer&);
+
+private:
+
+ bool mInitialized; ///< Whether the TTS player is initialised successfully or not
+ std::string mUnplayedString; ///< The text that can not be played because tts engine is not yet initialized
+ tts_h mTtsHandle; ///< The handle of TTS
+ int mUtteranceId; ///< The utterance ID
+
+ Dali::TtsPlayer::Mode mTtsMode; ///< The current mode of tts engine
+
+#if defined(DEBUG_ENABLED)
+public:
+ static Debug::Filter* gLogFilter;
+#endif
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Internal::Adaptor::TtsPlayer& GetImplementation(Dali::TtsPlayer& player)
+{
+ DALI_ASSERT_ALWAYS( player && "TtsPlayer handle is empty" );
+
+ BaseObject& handle = player.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::TtsPlayer&>(handle);
+}
+
+inline const Internal::Adaptor::TtsPlayer& GetImplementation(const Dali::TtsPlayer& player)
+{
+ DALI_ASSERT_ALWAYS( player && "TtsPlayer handle is empty" );
+
+ const BaseObject& handle = player.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::TtsPlayer&>(handle);
+}
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_TTS_PLAYER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <tts-player.h>
+
+// INTERNAL INCLUDES
+#include <tts-player-impl.h>
+#include <adaptor-impl.h>
+
+namespace Dali
+{
+
+TtsPlayer::TtsPlayer()
+{
+}
+
+TtsPlayer TtsPlayer::Get(Dali::TtsPlayer::Mode mode)
+{
+ TtsPlayer ttsPlayer;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ ttsPlayer = Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).GetTtsPlayer(mode);
+ }
+
+ return ttsPlayer;
+}
+
+TtsPlayer::~TtsPlayer()
+{
+}
+
+void TtsPlayer::Play(const std::string& text)
+{
+ return GetImplementation(*this).Play(text);
+}
+
+void TtsPlayer::Stop()
+{
+ GetImplementation(*this).Stop();
+}
+
+void TtsPlayer::Pause()
+{
+ GetImplementation(*this).Pause();
+}
+
+void TtsPlayer::Resume()
+{
+ GetImplementation(*this).Resume();
+}
+
+TtsPlayer::TtsPlayer( Internal::Adaptor::TtsPlayer* player )
+: BaseHandle( player )
+{
+}
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "virtual-keyboard-impl.h"
+
+// EXTERNAL INCLUDES
+#include <algorithm>
+
+#include <dali/public-api/common/vector-wrapper.h>
+#include <adaptor.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <locale-utils.h>
+#include <imf-manager-impl.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace VirtualKeyboard
+{
+
+namespace
+{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_VIRTUAL_KEYBOARD");
+#endif
+
+//forward declarations
+void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value );
+void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value );
+
+// Signals
+Dali::VirtualKeyboard::StatusSignalV2 gKeyboardStatusSignalV2;
+Dali::VirtualKeyboard::VoidSignalV2 gKeyboardResizeSignalV2;
+Dali::VirtualKeyboard::VoidSignalV2 gKeyboardLanguageChangedSignalV2;
+
+Dali::VirtualKeyboard::ReturnKeyType gReturnKeyType = Dali::VirtualKeyboard::DEFAULT; // the currently used return key type.
+
+void InputPanelStateChangeCallback( void* data, Ecore_IMF_Context* context, int value )
+{
+ switch (value)
+ {
+ case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_SHOW\n" );
+
+ gKeyboardStatusSignalV2.Emit( true );
+
+ break;
+ }
+
+ case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_HIDE\n" );
+
+ gKeyboardStatusSignalV2.Emit( false );
+
+ break;
+ }
+
+ case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
+ default:
+ {
+ // Do nothing
+ break;
+ }
+ }
+}
+
+void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "VKB InputPanelLanguageChangeCallback" );
+
+ // Emit the signal that the language has changed
+ gKeyboardLanguageChangedSignalV2.Emit();
+}
+
+void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "VKB InputPanelGeometryChangedCallback\n" );
+
+ // Emit signal that the keyboard is resized
+ gKeyboardResizeSignalV2.Emit();
+}
+
+} // unnamed namespace
+
+void ConnectCallbacks( Ecore_IMF_Context *imfContext )
+{
+ if( imfContext )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ConnectPanelCallbacks\n" );
+
+ ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, NULL );
+ ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, NULL );
+ ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback, NULL );
+ }
+}
+
+void DisconnectCallbacks( Ecore_IMF_Context *imfContext )
+{
+ if( imfContext )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "VKB DisconnectPanelCallbacks\n" );
+
+ ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback );
+ ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback );
+ ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback );
+ }
+}
+
+void Show()
+{
+ if( Dali::Adaptor::IsAvailable() )
+ {
+ Dali::ImfManager imfManager = ImfManager::Get();
+ Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+
+ if( imfContext )
+ {
+ ecore_imf_context_input_panel_show( imfContext );
+ }
+ }
+}
+
+void Hide()
+{
+ if( Dali::Adaptor::IsAvailable() )
+ {
+ Dali::ImfManager imfManager = ImfManager::Get();
+ Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+
+ if( imfContext )
+ {
+ ecore_imf_context_input_panel_hide( imfContext );
+ }
+ }
+}
+
+bool IsVisible()
+{
+ if( Dali::Adaptor::IsAvailable() )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "IsVisible\n" );
+
+ Dali::ImfManager imfManager = ImfManager::Get();
+ Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+
+ if ( imfContext )
+ {
+ if (ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_SHOW ||
+ ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+void SetReturnKeyType( Dali::VirtualKeyboard::ReturnKeyType type )
+{
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ Dali::ImfManager imfManager = ImfManager::Get();
+ Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+
+ if( imfContext )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "VKB Retrun key type is changed[%d]\n", type );
+
+ gReturnKeyType = type;
+ ecore_imf_context_input_panel_return_key_type_set( imfContext, static_cast<Ecore_IMF_Input_Panel_Return_Key_Type>( type ) );
+ }
+ }
+}
+
+Dali::VirtualKeyboard::ReturnKeyType GetReturnKeyType()
+{
+ return gReturnKeyType;
+}
+
+void EnablePrediction(const bool enable)
+{
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ Dali::ImfManager imfManager = ImfManager::Get();
+ Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+
+ if ( imfContext )
+ {
+ ecore_imf_context_prediction_allow_set( imfContext, (enable)? EINA_TRUE : EINA_FALSE);
+ }
+ }
+}
+
+bool IsPredictionEnabled()
+{
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ Dali::ImfManager imfManager = ImfManager::Get();
+ Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+
+ if ( imfContext )
+ {
+ // predictive text is enabled.
+ if ( ecore_imf_context_input_panel_enabled_get( imfContext ) == EINA_TRUE )
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+Rect<int> GetSizeAndPosition()
+{
+ int xPos, yPos, width, height;
+
+ width = height = xPos = yPos = 0;
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ Dali::ImfManager imfManager = ImfManager::Get();
+ Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+
+ if( imfContext )
+ {
+ ecore_imf_context_input_panel_geometry_get(imfContext, &xPos, &yPos, &width, &height);
+ }
+ else
+ {
+ DALI_LOG_WARNING("VKB Unable to get IMF Context so GetSize unavailable\n");
+ // return 0 as real size unknown.
+ }
+ }
+
+ return Rect<int>(xPos,yPos,width,height);
+}
+
+Dali::VirtualKeyboard::StatusSignalV2& StatusChangedSignal()
+{
+ return gKeyboardStatusSignalV2;
+}
+
+Dali::VirtualKeyboard::VoidSignalV2& ResizedSignal()
+{
+ return gKeyboardResizeSignalV2;
+}
+
+Dali::VirtualKeyboard::VoidSignalV2& LanguageChangedSignal()
+{
+ return gKeyboardLanguageChangedSignalV2;
+}
+
+Dali::VirtualKeyboard::TextDirection GetTextDirection()
+{
+ Dali::VirtualKeyboard::TextDirection direction ( Dali::VirtualKeyboard::LeftToRight );
+
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ Dali::ImfManager imfManager = ImfManager::Get();
+
+ if ( imfManager )
+ {
+ Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+
+ if ( imfContext )
+ {
+ char* locale( NULL );
+ ecore_imf_context_input_panel_language_locale_get( imfContext, &locale );
+
+ if ( locale )
+ {
+ direction = Locale::GetTextDirection( std::string( locale ) );
+ free( locale );
+ }
+ }
+ }
+ }
+ return direction;
+}
+
+} // namespace VirtualKeyboard
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_VIRTUAL_KEYBOARD_H__
+#define __DALI_INTERNAL_VIRTUAL_KEYBOARD_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <Ecore_IMF.h>
+
+// INTERNAL INCLUDES
+#include <virtual-keyboard.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Implementation of the virtual keyboard namespace
+ */
+namespace VirtualKeyboard
+{
+
+/**
+ * Connect the virtual keyboard callbacks.
+ * To get the virtual keyboard callbacks then you have to connect these callback.
+ * If you don't connect callbacks, you can't get virtual keyboard signals.
+ * The signals are StatusChangedSignal, ResizedSignal and LanguageChangedSignal.
+ */
+void ConnectCallbacks( Ecore_IMF_Context *imfContext );
+
+/**
+ * Disconnect the virtual keyboard callbacks.
+ * The signals are StatusChangedSignal, ResizedSignal and LanguageChangedSignal.
+ */
+void DisconnectCallbacks( Ecore_IMF_Context *imfContext );
+
+/**
+ * @copydoc Dali::VirtualKeyboard::Show()
+ */
+void Show();
+
+/**
+ * @copydoc Dali::VirtualKeyboard::Hide()
+ */
+void Hide();
+
+/**
+ * @copydoc Dali::VirtualKeyboard::IsVisible()
+ */
+bool IsVisible();
+
+/**
+ * @copydoc Dali::VirtualKeyboard::SetReturnKeyType()
+ */
+void SetReturnKeyType( Dali::VirtualKeyboard::ReturnKeyType type );
+
+/**
+ * @copydoc Dali::VirtualKeyboard::GetReturnKeyType()
+ */
+Dali::VirtualKeyboard::ReturnKeyType GetReturnKeyType();
+
+/**
+ * @copydoc Dali::VirtualKeyboard::EnablePrediction()
+ */
+void EnablePrediction(const bool enable);
+
+/**
+ * @copydoc Dali::VirtualKeyboard::IsPredictionEnabled()
+ */
+bool IsPredictionEnabled();
+
+/**
+ * @copydoc Dali::VirtualKeyboard::GetSizeAndPosition()
+ */
+Rect<int> GetSizeAndPosition();
+
+/**
+ * @copydoc Dali::VirtualKeyboard::RotateKeyboard()
+ */
+void RotateTo(int angle);
+
+/**
+ * @copydox Dali::VirtualKeyboard::StatusChangedSignal()
+ */
+Dali::VirtualKeyboard::StatusSignalV2& StatusChangedSignal();
+
+/**
+ * @copydox Dali::VirtualKeyboard::ResizedSignal()
+ */
+Dali::VirtualKeyboard::VoidSignalV2& ResizedSignal();
+
+/**
+ * @copydox Dali::VirtualKeyboard::LanguageChangedSignal()
+ */
+Dali::VirtualKeyboard::VoidSignalV2& LanguageChangedSignal();
+
+/**
+ * @copydoc Dali::VirtualKeyboard::GetTextDirection
+ */
+Dali::VirtualKeyboard::TextDirection GetTextDirection();
+
+} // namespace VirtualKeyboard
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_VIRTUAL_KEYBOARD_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <virtual-keyboard.h>
+
+// INTERNAL INCLUDES
+#include <virtual-keyboard-impl.h>
+
+namespace Dali
+{
+
+namespace VirtualKeyboard
+{
+
+void Show()
+{
+ Internal::Adaptor::VirtualKeyboard::Show();
+}
+
+void Hide()
+{
+ Internal::Adaptor::VirtualKeyboard::Hide();
+}
+
+bool IsVisible()
+{
+ return Internal::Adaptor::VirtualKeyboard::IsVisible();
+}
+
+void SetReturnKeyType( ReturnKeyType type )
+{
+ Internal::Adaptor::VirtualKeyboard::SetReturnKeyType( type );
+}
+
+ReturnKeyType GetReturnKeyType()
+{
+ return Internal::Adaptor::VirtualKeyboard::GetReturnKeyType();
+}
+
+void EnablePrediction(const bool enable)
+{
+ Internal::Adaptor::VirtualKeyboard::EnablePrediction(enable);
+}
+
+bool IsPredictionEnabled()
+{
+ return Internal::Adaptor::VirtualKeyboard::IsPredictionEnabled();
+}
+
+Rect<int> GetSizeAndPosition()
+{
+ return Internal::Adaptor::VirtualKeyboard::GetSizeAndPosition();
+}
+
+void RotateTo(int angle)
+{
+ Internal::Adaptor::VirtualKeyboard::RotateTo(angle);
+}
+
+StatusSignalV2& StatusChangedSignal()
+{
+ return Internal::Adaptor::VirtualKeyboard::StatusChangedSignal();
+}
+
+VoidSignalV2& ResizedSignal()
+{
+ return Internal::Adaptor::VirtualKeyboard::ResizedSignal();
+}
+
+VoidSignalV2& LanguageChangedSignal()
+{
+ return Internal::Adaptor::VirtualKeyboard::LanguageChangedSignal();
+}
+
+TextDirection GetTextDirection()
+{
+ return Internal::Adaptor::VirtualKeyboard::GetTextDirection();
+}
+
+} // namespace VirtualKeyboard
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include "vsync-monitor.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VSYNC_MONITOR");
+#endif
+
+const char * const DRM_DEVICE( "/dev/dri/card0" );
+const int FD_NONE( -1 );
+
+void ScreenStatusChanged(keynode_t* node, void* data)
+{
+ VSyncMonitor* vsyncMonitor( static_cast< VSyncMonitor* >( data ) );
+
+ int status = 0;
+ vconf_get_int( VCONFKEY_PM_STATE, &status );
+
+ // status values
+ // - VCONFKEY_PM_STATE_NORMAL : turn vsync on
+ // - VCONFKEY_PM_STATE_LCDDIM : turn vsync off
+ // - VCONFKEY_PM_STATE_LCDOFF : turn vsync off
+ // - VCONFKEY_PM_STATE_SLEEP : turn vsync off
+ const bool screenOn( VCONFKEY_PM_STATE_NORMAL == status );
+
+ vsyncMonitor->SetUseHardware( screenOn );
+
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "%s, Screen %s.\n", __PRETTY_FUNCTION__, screenOn ? "On" : "Off" );
+}
+
+} // unnamed namespace
+
+VSyncMonitor::VSyncMonitor()
+: mFileDescriptor( FD_NONE ),
+ mUseHardware( true )
+{
+ vconf_notify_key_changed( VCONFKEY_PM_STATE, ScreenStatusChanged, this );
+}
+
+VSyncMonitor::~VSyncMonitor()
+{
+ Terminate();
+
+ vconf_ignore_key_changed( VCONFKEY_PM_STATE, ScreenStatusChanged );
+}
+
+void VSyncMonitor::SetUseHardware( bool useHardware )
+{
+ mUseHardware = useHardware;
+}
+
+void VSyncMonitor::Initialize()
+{
+ DALI_ASSERT_DEBUG( mFileDescriptor == FD_NONE && "VSyncMonitor::Initialize() called twice" );
+
+ // Read initial 'use hardware' status
+ ScreenStatusChanged( NULL, this );
+
+ // open /dev node
+ mFileDescriptor = open( DRM_DEVICE, O_RDWR );
+
+ // setup vblank request - block and wait for next vblank
+ mVBlankInfo.request.type = DRM_VBLANK_NEXTONMISS;
+ mVBlankInfo.request.sequence = 0;
+ mVBlankInfo.request.signal = 0;
+
+ // setup vblank reply - block and wait for next vblank
+ mVBlankInfo.reply.type = DRM_VBLANK_NEXTONMISS;
+ mVBlankInfo.reply.sequence = 0;
+ mVBlankInfo.reply.tval_sec = 0;
+ mVBlankInfo.reply.tval_usec = 0;
+}
+
+void VSyncMonitor::Terminate()
+{
+ if( mFileDescriptor != FD_NONE )
+ {
+ close( mFileDescriptor );
+ mFileDescriptor = FD_NONE;
+ }
+}
+
+bool VSyncMonitor::UseHardware()
+{
+ return mUseHardware && (FD_NONE != mFileDescriptor );
+}
+
+
+bool VSyncMonitor::DoSync( unsigned int& frameNumber, unsigned int& seconds, unsigned int& microseconds )
+{
+ DALI_ASSERT_DEBUG( mFileDescriptor != FD_NONE && "ECoreX::VSyncMonitor is not initialized" );
+
+ if( 0 == drmWaitVBlank( mFileDescriptor, &mVBlankInfo ) )
+ {
+ frameNumber = mVBlankInfo.reply.sequence;
+ seconds = mVBlankInfo.reply.tval_sec;
+ microseconds = mVBlankInfo.reply.tval_usec;
+
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_VSYNC_MONITOR_IMPL_H__
+#define __DALI_INTERNAL_VSYNC_MONITOR_IMPL_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <xf86drm.h>
+
+// INTERNAL INCLUDES
+#include <base/interfaces/vsync-monitor-interface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Tizen interface for monitoring VSync
+ */
+class VSyncMonitor : public VSyncMonitorInterface
+{
+public:
+ /**
+ * Default constructor
+ */
+ VSyncMonitor();
+
+ /**
+ * Destructor
+ */
+ virtual ~VSyncMonitor();
+
+public:
+
+ /**
+ * Set the use hardware flag
+ * @param[in] useHardware The new state for the use hardware flag.
+ */
+ void SetUseHardware( bool useHardware );
+
+private: // From Dali::Internal::Adaptor::VSyncMonitorInterface
+
+ /**
+ * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::Initialize
+ */
+ virtual void Initialize();
+
+ /**
+ * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::Terminate
+ */
+ virtual void Terminate();
+
+ /**
+ * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::UseHardware
+ */
+ virtual bool UseHardware();
+
+ /**
+ * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::DoSync
+ */
+ virtual bool DoSync( unsigned int& frameNumber, unsigned int& seconds, unsigned int& microseconds );
+
+private:
+
+ int mFileDescriptor; ///< DRM dev node file descriptor
+ drmVBlank mVBlankInfo;
+ bool mUseHardware; ///< Hardware VSyncs available flag
+
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_VSYNC_MONITOR_IMPL_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "window-impl.h"
+
+// EXTERNAL HEADERS
+#include <Ecore.h>
+#ifdef WAYLAND
+#include <Ecore_Wayland.h>
+#else
+#include <Ecore_X.h>
+#endif
+
+#include <dali/integration-api/core.h>
+#include <dali/integration-api/system-overlay.h>
+#include <dali/public-api/render-tasks/render-task.h>
+#include <dali/public-api/render-tasks/render-task-list.h>
+#include <orientation.h>
+
+// INTERNAL HEADERS
+#ifdef WAYLAND
+#include <ecore-wl/wl-window-render-surface.h>
+#else
+#include <ecore-x/window-render-surface.h>
+#endif
+#include <drag-and-drop-detector-impl.h>
+#include <indicator-impl.h>
+#include <window-visibility-observer.h>
+#include <orientation-impl.h>
+
+namespace
+{
+const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
+const float INDICATOR_SHOW_Y_POSITION( 0.0f );
+const float INDICATOR_HIDE_Y_POSITION( -52.0f );
+}
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_WINDOW");
+#endif
+
+/**
+ * TODO: Abstract Window class out and move this into a window implementation for Ecore
+ */
+struct Window::EventHandler
+{
+ /**
+ * Constructor
+ * @param[in] window A pointer to the window class.
+ */
+ EventHandler( Window* window )
+ : mWindow( window ),
+#ifndef WAYLAND
+ mWindowPropertyHandler( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_PROPERTY, EcoreEventWindowPropertyChanged, this ) ),
+ mClientMessagehandler( ecore_event_handler_add( ECORE_X_EVENT_CLIENT_MESSAGE, EcoreEventClientMessage, this ) ),
+#endif
+ mEcoreWindow( 0 )
+ {
+#ifndef WAYLAND
+ // store ecore window handle
+ ECoreX::WindowRenderSurface* x11Window( dynamic_cast< ECoreX::WindowRenderSurface * >( mWindow->mSurface ) );
+ if( x11Window )
+ {
+ mEcoreWindow = x11Window->GetXWindow();
+ }
+ DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no ecore x window");
+
+ // set property on window to get deiconify approve client message
+ unsigned int tmp = 1;
+ ecore_x_window_prop_card32_set(mEcoreWindow,
+ ECORE_X_ATOM_E_DEICONIFY_APPROVE,
+ &tmp, 1);
+#endif
+ }
+
+ /**
+ * Destructor
+ */
+ ~EventHandler()
+ {
+ if ( mWindowPropertyHandler )
+ {
+ ecore_event_handler_del( mWindowPropertyHandler );
+ }
+ if ( mClientMessagehandler )
+ {
+ ecore_event_handler_del( mClientMessagehandler );
+ }
+ }
+
+ // Static methods
+
+ /// Called when the window properties are changed.
+ static Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
+ {
+#ifdef WAYLAND
+ return EINA_FALSE;
+#else
+ Ecore_X_Event_Window_Property* propertyChangedEvent( (Ecore_X_Event_Window_Property*)event );
+ EventHandler* handler( (EventHandler*)data );
+ Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
+
+ if ( handler && handler->mWindow )
+ {
+ WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
+ if ( observer && ( propertyChangedEvent->win == handler->mEcoreWindow ) )
+ {
+ Ecore_X_Window_State_Hint state( ecore_x_icccm_state_get( propertyChangedEvent->win ) );
+
+ switch ( state )
+ {
+ case ECORE_X_WINDOW_STATE_HINT_WITHDRAWN:
+ {
+ // Window was hidden.
+ observer->OnWindowHidden();
+ DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Withdrawn\n", handler->mEcoreWindow );
+ handled = ECORE_CALLBACK_DONE;
+ }
+ break;
+
+ case ECORE_X_WINDOW_STATE_HINT_ICONIC:
+ {
+ // Window was iconified (minimised).
+ observer->OnWindowHidden();
+ DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Iconfied\n", handler->mEcoreWindow );
+ handled = ECORE_CALLBACK_DONE;
+ }
+ break;
+
+ case ECORE_X_WINDOW_STATE_HINT_NORMAL:
+ {
+ // Window was shown.
+ observer->OnWindowShown();
+ DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Shown\n", handler->mEcoreWindow );
+ handled = ECORE_CALLBACK_DONE;
+ }
+ break;
+
+ default:
+ // Ignore
+ break;
+ }
+ }
+ }
+
+ return handled;
+#endif
+ }
+
+ /// Called when the window properties are changed.
+ static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
+ {
+#ifdef WAYLAND
+ return EINA_FALSE;
+#else
+ Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
+ Ecore_X_Event_Client_Message* clientMessageEvent( (Ecore_X_Event_Client_Message*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if (clientMessageEvent->message_type == ECORE_X_ATOM_E_DEICONIFY_APPROVE)
+ {
+ ECoreX::WindowRenderSurface* x11Window( dynamic_cast< ECoreX::WindowRenderSurface * >( handler->mWindow->mSurface ) );
+ WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
+
+ if ( observer && ( (unsigned int)clientMessageEvent->data.l[0] == handler->mEcoreWindow ) )
+ {
+ if (clientMessageEvent->data.l[1] == 0) //wm sends request message using value 0
+ {
+ observer->OnWindowShown();
+
+ // request to approve the deiconify. render-surface should send proper event after real rendering
+ if(x11Window)
+ {
+ x11Window->RequestToApproveDeiconify();
+ }
+
+ handled = ECORE_CALLBACK_DONE;
+ }
+ }
+ }
+
+ return handled;
+#endif
+ }
+
+ // Data
+ Window* mWindow;
+ Ecore_Event_Handler* mWindowPropertyHandler;
+ Ecore_Event_Handler* mClientMessagehandler;
+#ifdef WAYLAND
+ Ecore_Wl_Window* mEcoreWindow;
+#else
+ Ecore_X_Window mEcoreWindow;
+#endif
+};
+
+
+Window* Window::New(const PositionSize& posSize, const std::string& name, bool isTransparent)
+{
+ Window* window = new Window();
+ window->mIsTransparent = isTransparent;
+ window->Initialize(posSize, name);
+ return window;
+}
+
+void Window::SetAdaptor(Dali::Adaptor& adaptor)
+{
+ DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
+ mStarted = true;
+
+ // Only create one overlay per window
+ Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
+ Integration::Core& core = adaptorImpl.GetCore();
+ mOverlay = &core.GetSystemOverlay();
+
+ Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
+ taskList.CreateTask();
+
+ mAdaptor = &adaptorImpl;
+ mAdaptor->AddObserver( *this );
+
+ // Can only create the detector when we know the Core has been instantiated.
+ mDragAndDropDetector = DragAndDropDetector::New();
+ mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
+
+ if( mOrientation )
+ {
+ mOrientation->SetAdaptor(adaptor);
+ }
+
+ if( mIndicator != NULL )
+ {
+ mIndicator->SetAdaptor(mAdaptor);
+ }
+}
+
+RenderSurface* Window::GetSurface()
+{
+ return mSurface;
+}
+
+void Window::SetIndicatorStyle( Dali::Window::IndicatorStyle style )
+{
+ mIndicatorStyle = style;
+}
+
+void Window::ShowIndicator( bool show )
+{
+ DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "%s\n", show?"SHOW":"HIDE" );
+ DALI_ASSERT_DEBUG(mOverlay);
+
+ if(show)
+ {
+ mIndicatorVisible = Dali::Window::VISIBLE;
+ }
+ else
+ {
+ mIndicatorVisible = Dali::Window::INVISIBLE;
+ }
+
+ DoShowIndicator( mIndicatorOrientation );
+}
+
+void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
+{
+ DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
+ DALI_ASSERT_DEBUG(mOverlay);
+
+#ifndef WAYLAND
+ ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
+ DALI_ASSERT_DEBUG(x11Window);
+ Ecore_X_Window xWinId = x11Window->GetXWindow();
+
+ mIndicatorVisible = visibleMode;
+
+ if ( mIndicatorVisible == Dali::Window::VISIBLE )
+ {
+ // when the indicator is visible, set proper mode for indicator server according to bg mode
+ if ( mIndicatorOpacityMode == Dali::Window::OPAQUE )
+ {
+ ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_OPAQUE);
+ }
+ else if ( mIndicatorOpacityMode == Dali::Window::TRANSLUCENT )
+ {
+ ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
+ }
+#if defined(DALI_PROFILE_MOBILE)
+ else if ( mIndicatorOpacityMode == Dali::Window::TRANSPARENT )
+ {
+ ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_BG_TRANSPARENT);
+ }
+#endif
+ }
+ else
+ {
+ // when the indicator is not visible, set TRANSPARENT mode for indicator server
+ ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_TRANSPARENT); // it means hidden indicator
+ }
+#endif
+
+ DoShowIndicator( mIndicatorOrientation );
+}
+
+void Window::RotateIndicator(Dali::Window::WindowOrientation orientation)
+{
+ DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
+
+ DoRotateIndicator( orientation );
+}
+
+void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
+{
+ mIndicatorOpacityMode = opacityMode;
+
+ if( mIndicator != NULL )
+ {
+ mIndicator->SetOpacityMode( opacityMode );
+ }
+}
+
+void Window::SetClass(std::string name, std::string klass)
+{
+ // Get render surface's x11 window
+ if( mSurface )
+ {
+#ifndef WAYLAND
+ ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ ecore_x_icccm_name_class_set( x11Window->GetXWindow(), name.c_str(), klass.c_str() );
+ }
+#endif
+ }
+}
+
+Window::Window()
+: mSurface(NULL),
+ mIndicatorStyle(Dali::Window::CHANGEABLE_COLOR),
+ mIndicatorVisible(Dali::Window::VISIBLE),
+ mIndicatorIsShown(false),
+ mShowRotatedIndicatorOnClose(false),
+ mStarted(false),
+ mIsTransparent(false),
+ mWMRotationAppSet(false),
+ mIndicator(NULL),
+ mIndicatorOrientation(Dali::Window::PORTRAIT),
+ mNextIndicatorOrientation(Dali::Window::PORTRAIT),
+ mIndicatorOpacityMode(Dali::Window::OPAQUE),
+ mOverlay(NULL),
+ mAdaptor(NULL)
+{
+}
+
+Window::~Window()
+{
+ delete mEventHandler;
+
+ if ( mAdaptor )
+ {
+ mAdaptor->RemoveObserver( *this );
+ mAdaptor->SetDragAndDropDetector( NULL );
+ mAdaptor = NULL;
+ }
+
+ delete mSurface;
+}
+
+void Window::Initialize(const PositionSize& windowPosition, const std::string& name)
+{
+ // create an X11 window by default
+ Any surface;
+ Any display;
+#ifdef WAYLAND
+ mSurface = new ECoreWayland::WindowRenderSurface( windowPosition, surface, display, name, mIsTransparent );
+#else
+ mSurface = new ECoreX::WindowRenderSurface( windowPosition, surface, display, name, mIsTransparent );
+#endif
+ mOrientation = Orientation::New(this);
+
+ // create event handler for X11 window
+ mEventHandler = new EventHandler( this );
+}
+
+void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
+{
+ if( mIndicator == NULL )
+ {
+ if( mIndicatorVisible != Dali::Window::INVISIBLE )
+ {
+ mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, mIndicatorStyle, this );
+ mIndicator->SetOpacityMode( mIndicatorOpacityMode );
+ Dali::Actor actor = mIndicator->GetActor();
+ SetIndicatorActorRotation();
+ mOverlay->Add(actor);
+ }
+ // else don't create a hidden indicator
+ }
+ else // Already have indicator
+ {
+ if( mIndicatorVisible == Dali::Window::VISIBLE )
+ {
+ // If we are resuming, and rotation has changed,
+ if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
+ {
+ // then close current indicator and open new one
+ mShowRotatedIndicatorOnClose = true;
+ mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
+ // Don't show actor - will contain indicator for old orientation.
+ }
+ }
+ }
+
+ // set indicator visible mode
+ if( mIndicator != NULL )
+ {
+ mIndicator->SetVisible( mIndicatorVisible );
+ }
+
+ bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
+ SetIndicatorProperties( show, lastOrientation );
+ mIndicatorIsShown = show;
+}
+
+void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
+{
+ if( mIndicatorIsShown )
+ {
+ mShowRotatedIndicatorOnClose = true;
+ mNextIndicatorOrientation = orientation;
+ mIndicator->Close(); // May synchronously call IndicatorClosed() callback
+ }
+ else
+ {
+ // Save orientation for when the indicator is next shown
+ mShowRotatedIndicatorOnClose = false;
+ mNextIndicatorOrientation = orientation;
+ }
+}
+
+void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
+{
+#ifndef WAYLAND
+ ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window win = x11Window->GetXWindow();
+
+ int show_state = static_cast<int>( isShow );
+ ecore_x_window_prop_property_set( win,
+ ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE,
+ ECORE_X_ATOM_CARDINAL, 32, &show_state, 1);
+
+ if ( isShow )
+ {
+ ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_ON);
+ }
+ else
+ {
+ ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
+ }
+ }
+#endif
+}
+
+void Window::IndicatorTypeChanged(Indicator::Type type)
+{
+#ifndef WAYLAND
+ ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window win = x11Window->GetXWindow();
+ switch(type)
+ {
+ case Indicator::INDICATOR_TYPE_1:
+ ecore_x_e_illume_indicator_type_set( win, ECORE_X_ILLUME_INDICATOR_TYPE_1 );
+ break;
+
+ case Indicator::INDICATOR_TYPE_2:
+ ecore_x_e_illume_indicator_type_set( win, ECORE_X_ILLUME_INDICATOR_TYPE_2 );
+ break;
+
+ case Indicator::INDICATOR_TYPE_UNKNOWN:
+ default:
+ break;
+ }
+ }
+#endif
+}
+
+void Window::IndicatorClosed( Indicator* indicator )
+{
+ DALI_LOG_TRACE_METHOD( gWindowLogFilter );
+
+ if( mShowRotatedIndicatorOnClose )
+ {
+ Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
+ mIndicator->Open(mNextIndicatorOrientation);
+ mIndicatorOrientation = mNextIndicatorOrientation;
+ SetIndicatorActorRotation();
+ DoShowIndicator(currentOrientation);
+ }
+}
+
+void Window::SetIndicatorActorRotation()
+{
+ DALI_LOG_TRACE_METHOD( gWindowLogFilter );
+ DALI_ASSERT_DEBUG( mIndicator != NULL );
+
+ Dali::Actor actor = mIndicator->GetActor();
+ switch( mIndicatorOrientation )
+ {
+ case Dali::Window::PORTRAIT:
+ actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
+ actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ actor.SetRotation( Degree(0), Vector3::ZAXIS );
+ break;
+ case Dali::Window::PORTRAIT_INVERSE:
+ actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
+ actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ actor.SetRotation( Degree(180), Vector3::ZAXIS );
+ break;
+ case Dali::Window::LANDSCAPE:
+ actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
+ actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ actor.SetRotation( Degree(270), Vector3::ZAXIS );
+ break;
+ case Dali::Window::LANDSCAPE_INVERSE:
+ actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
+ actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ actor.SetRotation( Degree(90), Vector3::ZAXIS );
+ break;
+ }
+}
+
+void Window::Raise()
+{
+#ifndef WAYLAND
+ ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window win = x11Window->GetXWindow();
+ ecore_x_window_raise(win);
+ }
+#endif
+}
+
+void Window::Lower()
+{
+#ifndef WAYLAND
+ ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window win = x11Window->GetXWindow();
+ ecore_x_window_lower(win);
+ }
+#endif
+}
+
+void Window::Activate()
+{
+#ifndef WAYLAND
+ ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window win = x11Window->GetXWindow();
+ ecore_x_netwm_client_active_request(ecore_x_window_root_get(win), win, 1 /* request type, 1:application, 2:pager */, 0);
+ }
+#endif
+}
+
+Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
+{
+ return mDragAndDropDetector;
+}
+
+void Window::OnStart()
+{
+ DoShowIndicator( mIndicatorOrientation );
+}
+
+void Window::OnPause()
+{
+}
+
+void Window::OnResume()
+{
+ // resume indicator status
+ if( mIndicator != NULL )
+ {
+ // Restore own indicator opacity
+ // Send opacity mode to indicator service when app resumed
+ mIndicator->SetOpacityMode( mIndicatorOpacityMode );
+ }
+}
+
+void Window::OnStop()
+{
+ if( mIndicator )
+ {
+ mIndicator->Close();
+ }
+
+ delete mIndicator;
+ mIndicator = NULL;
+}
+
+void Window::OnDestroy()
+{
+ mAdaptor = NULL;
+}
+
+OrientationPtr Window::GetOrientation()
+{
+ return mOrientation;
+}
+
+void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
+{
+ bool found = false;
+
+ for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
+ {
+ if(mAvailableOrientations[i] == orientation)
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if( ! found )
+ {
+ mAvailableOrientations.push_back(orientation);
+ SetAvailableOrientations( mAvailableOrientations );
+ }
+}
+
+void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
+{
+ for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
+ iter != mAvailableOrientations.end(); ++iter )
+ {
+ if( *iter == orientation )
+ {
+ mAvailableOrientations.erase( iter );
+ break;
+ }
+ }
+ SetAvailableOrientations( mAvailableOrientations );
+}
+
+void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
+{
+ DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
+
+#ifndef WAYLAND
+ mAvailableOrientations = orientations;
+ ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
+ if( ! mWMRotationAppSet )
+ {
+ mWMRotationAppSet = true;
+ ecore_x_e_window_rotation_app_set(ecoreWindow, EINA_TRUE);
+ }
+
+ int rotations[4];
+ for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
+ {
+ rotations[i] = static_cast<int>(mAvailableOrientations[i]);
+ }
+ ecore_x_e_window_rotation_available_rotations_set(ecoreWindow, rotations, mAvailableOrientations.size() );
+
+ }
+#endif
+}
+
+const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
+{
+ return mAvailableOrientations;
+}
+
+void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
+{
+ mPreferredOrientation = orientation;
+
+#ifndef WAYLAND
+ ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
+
+ if( ! mWMRotationAppSet )
+ {
+ mWMRotationAppSet = true;
+ ecore_x_e_window_rotation_app_set(ecoreWindow, EINA_TRUE);
+ }
+
+ ecore_x_e_window_rotation_preferred_rotation_set(ecoreWindow, orientation);
+ }
+#endif
+}
+
+Dali::Window::WindowOrientation Window::GetPreferredOrientation()
+{
+ return mPreferredOrientation;
+}
+
+void Window::RotationDone( int orientation, int width, int height )
+{
+#ifndef WAYLAND
+ // Tell window manager we're done
+ ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
+ Ecore_X_Window root = ecore_x_window_root_get(ecoreWindow);
+
+ /**
+ * send rotation done message to wm, even if window is already rotated.
+ * that's why wm must be wait for comming rotation done message
+ * after sending rotation request.
+ */
+ ecore_x_e_window_rotation_change_done_send(root, ecoreWindow, orientation, width, height);
+
+ /**
+ * set rotate window property
+ */
+ int angles[2] = { orientation, orientation };
+ ecore_x_window_prop_property_set( ecoreWindow,
+ ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
+ ECORE_X_ATOM_CARDINAL, 32, &angles, 2 );
+ }
+#endif
+}
+
+
+} // Adaptor
+} // Internal
+} // Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_WINDOW_H__
+#define __DALI_INTERNAL_WINDOW_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/object/base-object.h>
+#include <window.h>
+#include <orientation.h>
+#include <render-surface.h>
+#include <drag-and-drop-detector.h>
+
+// INTERNAL INCLUDES
+#include <base/lifecycle-observer.h>
+#include <adaptor-impl.h>
+#include <indicator-impl.h>
+
+
+namespace Dali
+{
+class Adaptor;
+
+namespace Integration
+{
+class SystemOverlay;
+}
+
+namespace Internal
+{
+namespace Adaptor
+{
+class RenderSurface;
+class Indicator;
+class Orientation;
+
+class Window;
+typedef IntrusivePtr<Window> WindowPtr;
+typedef IntrusivePtr<Orientation> OrientationPtr;
+
+/**
+ * Window provides a surface to render onto with orientation & indicator properties.
+ */
+class Window : public Dali::BaseObject, public Indicator::Observer, public LifeCycleObserver
+{
+public:
+ /**
+ * Create a new Window. This should only be called once by the Application class
+ * @param[in] windowPosition The position and size of the window
+ * @param[in] name The window title
+ * @param[in] isTransparent Whether window is transparent
+ * @return A newly allocated Window
+ */
+ static Window* New(const PositionSize& posSize, const std::string& name, bool isTransparent = false);
+
+ /**
+ * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
+ * @param[in] adaptor An initialized adaptor
+ */
+ void SetAdaptor(Dali::Adaptor& adaptor);
+
+ /**
+ * Get the window surface
+ * @return The render surface
+ */
+ RenderSurface* GetSurface();
+
+ /**
+ * @copydoc Dali::Window::SetIndicatorStyle()
+ */
+ void SetIndicatorStyle( Dali::Window::IndicatorStyle style );
+
+ /**
+ * @copydoc Dali::Window::ShowIndicator()
+ */
+ void ShowIndicator( bool show );
+
+ /**
+ * @copydoc Dali::Window::ShowIndicator()
+ */
+ void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
+
+ /**
+ * @copydoc Dali::Window::SetIndicatorBgOpacity()
+ */
+ void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
+
+ /**
+ * @copydoc Dali::Window::RotateIndicator()
+ */
+ void RotateIndicator( Dali::Window::WindowOrientation orientation );
+
+ /**
+ * @copydoc Dali::Window::SetClass()
+ */
+ void SetClass( std::string name, std::string klass );
+
+ /**
+ * @copydoc Dali::Window::Raise()
+ */
+ void Raise();
+
+ /**
+ * @copydoc Dali::Window::Lower()
+ */
+ void Lower();
+
+ /**
+ * @copydoc Dali::Window::Activate()
+ */
+ void Activate();
+
+ /**
+ * @copydoc Dali::Window::GetOrientation()
+ */
+ OrientationPtr GetOrientation();
+
+ /**
+ * @copydoc Dali::Window::AddAvailableOrientation()
+ */
+ void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
+
+ /**
+ * @copydoc Dali::Window::RemoveAvailableOrientation()
+ */
+ void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
+
+ /**
+ * @copydoc Dali::Window::SetAvailableOrientations()
+ */
+ void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
+
+ /**
+ * @copydoc Dali::Window::GetAvailableOrientations()
+ */
+ const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
+
+ /**
+ * @copydoc Dali::Window::SetPreferredOrientation()
+ */
+ void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
+
+ /**
+ * @copydoc Dali::Window::GetPreferredOrientation()
+ */
+ Dali::Window::WindowOrientation GetPreferredOrientation();
+
+ /**
+ * @copydoc Dali::Window::GetDragAndDropDetector() const
+ */
+ Dali::DragAndDropDetector GetDragAndDropDetector() const;
+
+ /**
+ * Called from Orientation after the Change signal has been sent
+ */
+ void RotationDone( int orientation, int width, int height );
+
+
+private:
+ /**
+ * Private constructor.
+ * @sa Window::New()
+ */
+ Window();
+
+ /**
+ * Destructor
+ */
+ virtual ~Window();
+
+ /**
+ * Second stage initialization
+ */
+ void Initialize(const PositionSize& posSize, const std::string& name);
+
+ /**
+ * Shows / hides the indicator bar.
+ * Handles close/open if rotation changes whilst hidden
+ */
+ void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
+
+ /**
+ * Close current indicator and open a connection onto the new indicator service.
+ * Effect may not be synchronous if waiting for an indicator update on existing connection.
+ */
+ void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
+
+ /**
+ * Change the indicator actor's rotation to match the current orientation
+ */
+ void SetIndicatorActorRotation();
+
+ /**
+ * Set the indicator properties on the window
+ */
+ void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
+
+private: // Indicator::Observer interface
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorTypeChanged()
+ */
+ virtual void IndicatorTypeChanged( Indicator::Type type );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorClosed()
+ */
+ virtual void IndicatorClosed(Indicator* indicator);
+
+private: // Adaptor::Observer interface
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
+ */
+ virtual void OnStart();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
+ */
+ virtual void OnPause();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
+ */
+ virtual void OnResume();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
+ */
+ virtual void OnStop();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
+ */
+ virtual void OnDestroy();
+
+private:
+
+ typedef std::vector<Indicator*> DiscardedIndicators;
+
+ RenderSurface* mSurface;
+ Dali::Window::IndicatorStyle mIndicatorStyle; ///< indicator style
+ Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
+ bool mIndicatorIsShown:1; ///< private state
+ bool mShowRotatedIndicatorOnClose:1;
+ bool mStarted:1;
+ bool mIsTransparent:1;
+ bool mWMRotationAppSet:1;
+ Indicator* mIndicator;
+ Dali::Window::WindowOrientation mIndicatorOrientation;
+ Dali::Window::WindowOrientation mNextIndicatorOrientation;
+ Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
+ Integration::SystemOverlay* mOverlay;
+ Adaptor* mAdaptor;
+ Dali::DragAndDropDetector mDragAndDropDetector;
+
+ struct EventHandler;
+ EventHandler* mEventHandler;
+
+ OrientationPtr mOrientation;
+ std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
+ Dali::Window::WindowOrientation mPreferredOrientation;
+};
+
+} // namespace Adaptor
+} // namepsace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
+{
+ DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
+ BaseObject& object = window.GetBaseObject();
+ return static_cast<Internal::Adaptor::Window&>(object);
+}
+
+inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
+{
+ DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
+ const BaseObject& object = window.GetBaseObject();
+ return static_cast<const Internal::Adaptor::Window&>(object);
+}
+
+} // namespace Dali
+
+
+#endif // __DALI_INTERNAL_WINDOW_H__
--- /dev/null
+#ifndef __DALI_INTERNAL_WINDOW_VISIBILITY_OBSERVER_H__
+#define __DALI_INTERNAL_WINDOW_VISIBILITY_OBSERVER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * An interface used to observe when the application's window is shown/hidden.
+ */
+class WindowVisibilityObserver
+{
+public:
+
+ /**
+ * Called when the window becomes fully or partially visible.
+ */
+ virtual void OnWindowShown() = 0;
+
+ /**
+ * Called when the window is fully hidden.
+ */
+ virtual void OnWindowHidden() = 0;
+
+protected:
+
+ /**
+ * Protected Constructor.
+ */
+ WindowVisibilityObserver()
+ {
+ }
+
+ /**
+ * Protected virtual destructor.
+ */
+ virtual ~WindowVisibilityObserver()
+ {
+ }
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_WINDOW_VISIBILITY_OBSERVER_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <window.h>
+
+// INTERNAL INCLUDES
+#include <window-impl.h>
+#include <orientation-impl.h>
+
+namespace Dali
+{
+
+Window Window::New(PositionSize posSize, const std::string name, bool isTransparent)
+{
+ Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, isTransparent);
+ return Window(window);
+}
+
+Window::Window()
+{
+}
+
+Window::~Window()
+{
+}
+
+void Window::SetIndicatorStyle( IndicatorStyle style )
+{
+ GetImplementation(*this).SetIndicatorStyle( style );
+}
+
+void Window::ShowIndicator( bool show )
+{
+ GetImplementation(*this).ShowIndicator( show );
+}
+
+void Window::ShowIndicator( IndicatorVisibleMode visibleMode )
+{
+ GetImplementation(*this).ShowIndicator( visibleMode );
+}
+
+void Window::SetIndicatorBgOpacity( IndicatorBgOpacity opacity )
+{
+ GetImplementation(*this).SetIndicatorBgOpacity( opacity );
+}
+
+void Window::RotateIndicator( WindowOrientation orientation )
+{
+ GetImplementation(*this).RotateIndicator( orientation );
+}
+
+void Window::SetClass( std::string name, std::string klass )
+{
+ GetImplementation(*this).SetClass( name, klass );
+}
+
+void Window::Raise()
+{
+ GetImplementation(*this).Raise();
+}
+
+void Window::Lower()
+{
+ GetImplementation(*this).Lower();
+}
+
+void Window::Activate()
+{
+ GetImplementation(*this).Activate();
+}
+
+Orientation Window::GetOrientation()
+{
+ Internal::Adaptor::OrientationPtr orientation = GetImplementation(*this).GetOrientation();
+ return Orientation(orientation.Get());
+}
+
+void Window::AddAvailableOrientation( WindowOrientation orientation )
+{
+ GetImplementation(*this).AddAvailableOrientation( orientation );
+}
+
+void Window::RemoveAvailableOrientation( WindowOrientation orientation )
+{
+ GetImplementation(*this).RemoveAvailableOrientation( orientation );
+}
+
+void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
+{
+ GetImplementation(*this).SetAvailableOrientations( orientations );
+}
+
+const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
+{
+ return GetImplementation(*this).GetAvailableOrientations();
+}
+
+void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
+{
+ GetImplementation(*this).SetPreferredOrientation( orientation );
+}
+
+Dali::Window::WindowOrientation Window::GetPreferredOrientation()
+{
+ return GetImplementation(*this).GetPreferredOrientation();
+}
+
+DragAndDropDetector Window::GetDragAndDropDetector() const
+{
+ return GetImplementation(*this).GetDragAndDropDetector();
+}
+
+Window::Window( Internal::Adaptor::Window* window )
+: BaseHandle( window )
+{
+}
+
+} // namespace Dali
--- /dev/null
+# Application
+
+tizen_evas_plugin_internal_src_files = \
+ $(tizen_evas_plugin_internal_src_dir)/evas-plugin-impl.cpp
+
+tizen_native_buffer_plugin_internal_src_files = \
+ $(tizen_native_buffer_plugin_internal_src_dir)/native-buffer-plugin-impl.cpp
+
+# Public source files
+tizen_evas_plugin_public_api_src_files = \
+ $(tizen_evas_plugin_public_api_src_dir)/evas-plugin.cpp
+
+tizen_native_buffer_plugin_public_api_src_files = \
+ $(tizen_native_buffer_plugin_public_api_src_dir)/native-buffer-plugin.cpp
+
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "evas-plugin-impl.h"
+
+// EXTERNAL HEADERS
+#include <dali/public-api/dali-core.h>
+#include <dali/integration-api/debug.h>
+
+#include <Ecore_IMF_Evas.h>
+
+// INTERNAL HEADERS
+#include <accessibility-manager.h>
+#include <clipboard-event-notifier.h>
+#include <imf-manager.h>
+
+#include <adaptor-impl.h>
+#include "mobile-render-surface-factory.h"
+#include <pixmap-render-surface.h>
+#include <trigger-event.h>
+
+namespace Dali
+{
+
+namespace SlpPlatform
+{
+class SlpPlatformAbstraction;
+}
+
+namespace Integration
+{
+class Core;
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gEvasPluginLogFilter = Debug::Filter::New(Debug::Verbose, true, "LOG_EVAS_PLUGIN");
+#endif
+
+const char * CLIPBOARD_ATOM = "CBHM_MSG";
+const char * CLIPBOARD_SET_OWNER_MESSAGE = "SET_OWNER";
+
+/**
+ * Evas_Modifier enums in Ecore_Input.h do not match Ecore_Event_Modifier in Ecore_Input.h.
+ * This function converts from Evas_Modifier to Ecore_Event_Modifier enums.
+ * @param[in] evasModifier the Evas_Modifier input.
+ * @return the Ecore_Event_Modifier output.
+ */
+unsigned int EvasModifierToEcoreModifier(Evas_Modifier* evasModifier)
+{
+ Eina_Bool control, alt, shift, altGr, win;
+
+ control = evas_key_modifier_is_set(evasModifier, "Control");
+ alt = evas_key_modifier_is_set(evasModifier, "Alt");
+ shift = evas_key_modifier_is_set(evasModifier, "Shift");
+ altGr = evas_key_modifier_is_set(evasModifier, "AltGr");
+ win = evas_key_modifier_is_set(evasModifier, "Win");
+ win = evas_key_modifier_is_set(evasModifier, "Super");
+ win = evas_key_modifier_is_set(evasModifier, "Hyper");
+
+ unsigned int modifier( 0 ); // If no other matches returns NONE.
+
+ if ( shift )
+ {
+ modifier |= ECORE_EVENT_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
+ }
+
+ if ( alt )
+ {
+ modifier |= ECORE_EVENT_MODIFIER_ALT;
+ }
+
+ if ( control )
+ {
+ modifier |= ECORE_EVENT_MODIFIER_CTRL;
+ }
+
+ if ( win )
+ {
+ modifier |= ECORE_EVENT_MODIFIER_WIN;
+ }
+
+ if ( altGr )
+ {
+ modifier |= ECORE_EVENT_MODIFIER_ALTGR;
+ }
+
+ return modifier;
+}
+
+static void _evas_object_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep)
+ {
+ Evas_Event_Mouse_Down* ev;
+ ev = (Evas_Event_Mouse_Down *)event_info;
+
+ Evas_Coord rel_x, rel_y;
+ Evas_Coord obj_x, obj_y, obj_w, obj_h;
+ evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
+
+ rel_x = ev->canvas.x - obj_x;
+ rel_y = ev->canvas.y - obj_y;
+
+ // create dali TouchEvent & SendEvent
+ TouchPoint point(0, TouchPoint::Down, rel_x, rel_y);
+ ep->OnTouchEvent(point, ev->timestamp);
+ }
+}
+
+static void _evas_object_mouse_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep)
+ {
+ Evas_Event_Mouse_Move *ev;
+ ev = (Evas_Event_Mouse_Move *)event_info;
+
+ Evas_Coord rel_x, rel_y;
+ Evas_Coord obj_x, obj_y, obj_w, obj_h;
+ evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
+
+ rel_x = ev->cur.canvas.x - obj_x;
+ rel_y = ev->cur.canvas.y - obj_y;
+
+ // create dali TouchEvent & SendEvent
+ TouchPoint point(0, TouchPoint::Motion, rel_x, rel_y);
+ ep->OnTouchEvent(point, ev->timestamp);
+ }
+}
+
+static void _evas_object_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep)
+ {
+ Evas_Event_Mouse_Up *ev;
+ ev = (Evas_Event_Mouse_Up *)event_info;
+
+ Evas_Coord rel_x, rel_y;
+ Evas_Coord obj_x, obj_y, obj_w, obj_h;
+ evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
+
+ rel_x = ev->canvas.x - obj_x;
+ rel_y = ev->canvas.y - obj_y;
+
+ // create dali TouchEvent & SendEvent
+ TouchPoint point(0, TouchPoint::Up, rel_x, rel_y);
+ ep->OnTouchEvent(point, ev->timestamp);
+ }
+}
+
+static void _evas_object_mouse_wheel_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep)
+ {
+ Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*)event_info;
+ Evas_Coord rel_x, rel_y;
+ Evas_Coord obj_x, obj_y, obj_w, obj_h;
+ evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
+
+ rel_x = ev->canvas.x - obj_x;
+ rel_y = ev->canvas.y - obj_y;
+
+ MouseWheelEvent wheelEvent(ev->direction, -1 /*Need to check evas modifier*/, Vector2(rel_x, rel_y), ev->z, ev->timestamp);
+ ep->OnMouseWheelEvent(wheelEvent);
+ }
+}
+
+static void _evas_object_multi_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep)
+ {
+ Evas_Event_Multi_Down *ev = (Evas_Event_Multi_Down*)event_info;
+
+ Evas_Coord rel_x, rel_y;
+ Evas_Coord obj_x, obj_y, obj_w, obj_h;
+ evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
+
+ rel_x = ev->canvas.x - obj_x;
+ rel_y = ev->canvas.y - obj_y;
+
+ // create dali TouchEvent & SendEvent
+ TouchPoint point(ev->device, TouchPoint::Down, rel_x, rel_y);
+ ep->OnTouchEvent(point, ev->timestamp);
+ }
+}
+
+static void _evas_object_multi_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep)
+ {
+ Evas_Event_Multi_Up *ev = (Evas_Event_Multi_Up*)event_info;
+
+ Evas_Coord rel_x, rel_y;
+ Evas_Coord obj_x, obj_y, obj_w, obj_h;
+ evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
+
+ rel_x = ev->canvas.x - obj_x;
+ rel_y = ev->canvas.y - obj_y;
+
+ // create dali TouchEvent & SendEvent
+ TouchPoint point(ev->device, TouchPoint::Up, rel_x, rel_y);
+ ep->OnTouchEvent(point, ev->timestamp);
+ }
+}
+static void _evas_object_multi_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep)
+ {
+ Evas_Event_Multi_Move *ev = (Evas_Event_Multi_Move*)event_info;
+
+ Evas_Coord rel_x, rel_y;
+ Evas_Coord obj_x, obj_y, obj_w, obj_h;
+ evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
+
+ rel_x = ev->cur.canvas.x - obj_x;
+ rel_y = ev->cur.canvas.y - obj_y;
+
+ // create dali TouchEvent & SendEvent
+ TouchPoint point(ev->device, TouchPoint::Motion, rel_x, rel_y);
+ ep->OnTouchEvent(point, ev->timestamp);
+ }
+}
+
+static void _evas_object_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+
+ if(ep)
+ {
+ Evas_Event_Key_Down* keyEvent( (Evas_Event_Key_Down*)event_info );
+ bool eventHandled( false );
+
+ if(!keyEvent->keyname)
+ {
+ return;
+ }
+
+ Ecore_IMF_Context* imfContext = NULL;
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ Dali::ImfManager imfManager = Dali::ImfManager::Get();
+ if ( imfManager )
+ {
+ imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ }
+ }
+
+ // XF86Stop and XF86Send must skip ecore_imf_context_filter_event.
+ if ( imfContext && strcmp( keyEvent->keyname, "XF86Send" ) && strcmp( keyEvent->keyname, "XF86Phone" ) && strcmp( keyEvent->keyname, "XF86Stop" ) )
+ {
+ Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
+ ecore_imf_evas_event_key_down_wrap(keyEvent, &ecoreKeyDownEvent);
+
+ eventHandled = ecore_imf_context_filter_event(imfContext,
+ ECORE_IMF_EVENT_KEY_DOWN,
+ (Ecore_IMF_Event *) &ecoreKeyDownEvent );
+
+ // If the event has not been handled by IMF then check if we should reset our IMF context
+ if( !eventHandled )
+ {
+ if ( !strcmp( keyEvent->keyname, "Escape" ) ||
+ !strcmp( keyEvent->keyname, "Return" ) ||
+ !strcmp( keyEvent->keyname, "KP_Enter" ) )
+ {
+ ecore_imf_context_reset( imfContext );
+ }
+ }
+ }
+
+ // If the event wasn't handled then we should send a key event.
+ if ( !eventHandled )
+ {
+ std::string keyName( keyEvent->keyname );
+ std::string keyString( "" );
+ int keyCode = ecore_x_keysym_keycode_get(keyEvent->keyname);
+ int modifier( EvasModifierToEcoreModifier ( keyEvent->modifiers ) );
+ unsigned long time( keyEvent->timestamp );
+
+ // Ensure key event string is not NULL as keys like SHIFT have a null string.
+ if ( keyEvent->string )
+ {
+ keyString = keyEvent->string;
+ }
+
+ KeyEvent daliKeyEvent(keyName, keyString, keyCode, modifier, time, KeyEvent::Down);
+ ep->OnKeyEvent( daliKeyEvent );
+ }
+ }
+}
+
+static void _evas_object_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep)
+ {
+ // We're consuming key up event so we have to pass to IMF so that it can parse it as well.
+ Evas_Event_Key_Up* keyEvent( (Evas_Event_Key_Up*)event_info );
+ bool eventHandled( false );
+
+ Ecore_IMF_Context* imfContext = NULL;
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ Dali::ImfManager imfManager = Dali::ImfManager::Get();
+ if ( imfManager )
+ {
+ imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ }
+ }
+
+ if ( imfContext && strcmp( keyEvent->keyname, "XF86Send" ) && strcmp( keyEvent->keyname, "XF86Phone" ) && strcmp( keyEvent->keyname, "XF86Stop" ))
+ {
+ Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
+ ecore_imf_evas_event_key_up_wrap(keyEvent, &ecoreKeyUpEvent);
+
+ eventHandled = ecore_imf_context_filter_event( imfContext,
+ ECORE_IMF_EVENT_KEY_UP,
+ (Ecore_IMF_Event *) &ecoreKeyUpEvent );
+ }
+
+ if ( !eventHandled )
+ {
+ std::string keyName( keyEvent->keyname );
+ std::string keyString( "" );
+ int keyCode = ecore_x_keysym_keycode_get(keyEvent->keyname);
+ int modifier( EvasModifierToEcoreModifier ( keyEvent->modifiers ) );
+ unsigned long time( keyEvent->timestamp );
+
+ // Ensure key event string is not NULL as keys like SHIFT have a null string.
+ if ( keyEvent->string )
+ {
+ keyString = keyEvent->string;
+ }
+
+ KeyEvent daliKeyEvent(keyName, keyString, keyCode, modifier, time, KeyEvent::Up);
+ ep->OnKeyEvent( daliKeyEvent );
+ }
+ }
+}
+
+static void _evas_object_focus_in_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep != NULL && ep->GetEvasImageObject() == obj)
+ {
+ ep->OnEvasObjectFocusedIn();
+ }
+}
+
+static void _evas_object_focus_out_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep != NULL && ep->GetEvasImageObject() == obj)
+ {
+ ep->OnEvasObjectFocusedOut();
+ }
+}
+
+static void _elm_focus_object_focus_in_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep != NULL && ep->GetElmFocusObject() == obj)
+ {
+ Evas_Object* win = elm_object_top_widget_get(obj);
+ if(strcmp("elm_win", elm_object_widget_type_get(win)) == 0)
+ {
+ if(elm_win_focus_highlight_enabled_get(win) == EINA_TRUE)
+ {
+ // To allow that KeyboardFocusManager can handle the keyboard focus
+ KeyEvent fakeKeyEvent("", "", 0, 0, 100 /* fake timestamp */, KeyEvent::Down);
+ ep->OnKeyEvent( fakeKeyEvent );
+ }
+ }
+ else
+ {
+ DALI_LOG_ERROR("It is not elm win\n");
+ }
+
+ evas_object_focus_set(ep->GetEvasImageObject(), EINA_TRUE);
+ }
+}
+
+static void _elm_focus_object_focus_out_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep != NULL && ep->GetElmFocusObject() == obj)
+ {
+ evas_object_focus_set(ep->GetEvasImageObject(), EINA_FALSE);
+ }
+}
+
+static void _canvas_focus_in_cb(void *data, Evas *e, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep != NULL && ep->GetEvasImageObject() == evas_focus_get(e))
+ {
+ ep->OnEvasObjectFocusedIn();
+ }
+}
+
+static void _canvas_focus_out_cb(void *data, Evas *e, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep != NULL && ep->GetEvasImageObject() == evas_focus_get(e))
+ {
+ ep->OnEvasObjectFocusedOut();
+ }
+}
+
+static void _evas_object_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep)
+ {
+ ep->Move();
+ }
+}
+
+static void _evas_object_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep)
+ {
+ ep->Resize();
+ }
+}
+
+static void _evas_render_post_cb(void *data, Evas *e, void *event_info)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ if(ep)
+ {
+ // call RenderSync when the window surface(onscreen) was presented to LCD.
+ ep->RenderSync();
+
+ //After first render emit signal to notify
+ if(!ep->mFirstRenderCompleteNotified)
+ {
+ ep->OnFirstRenderCompleted();
+ }
+ }
+}
+
+/*
+ * When the evas plugin is resumed,
+ * need to forcely dirty set the evas object on idle time to show again the result of dali rendering.
+ * One time should be enough.
+ */
+static Eina_Bool _evas_object_dirty_set_idle_cb(void *data)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+
+ if(ep)
+ {
+ Evas_Object* eo = ep->GetEvasImageObject();
+ if(eo)
+ {
+ /* dirty set to post the result of rendering via evas */
+ evas_object_image_pixels_dirty_set(eo, EINA_TRUE);
+ }
+
+ ep->ClearIdler(false); // clear idler handle without deleting handle. because handle will be deleted by ecore
+ }
+
+ // we need it once.
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _elm_access_highlight_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ bool ret = false;
+
+ if(ep && actionInfo)
+ {
+ // action_by has NEXT or PREV
+ if (actionInfo->action_by == ELM_ACCESS_ACTION_HIGHLIGHT_NEXT)
+ {
+ ret = ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_HIGHLIGHT_NEXT, actionInfo);
+ DALI_LOG_INFO(gEvasPluginLogFilter, Debug::General, "[%s:%d] Next returns %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+ }
+ else if (actionInfo->action_by == ELM_ACCESS_ACTION_HIGHLIGHT_PREV)
+ {
+ ret = ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_HIGHLIGHT_PREV, actionInfo);
+ DALI_LOG_INFO(gEvasPluginLogFilter, Debug::General, "[%s:%d] Prev returns %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+ }
+ else
+ {
+ /*
+ * In case of access over, action_by has ELM_ACCESS_ACTION_HIGHLIGHT
+ * real operation will be done in _elm_access_over_cb
+ * so just return true in order to remove the entire focus indicator
+ */
+
+ /*
+ * Even if action_by has intialized value (-1), highlight action is valid
+ */
+ ret = true;
+ }
+ }
+ else
+ {
+ DALI_LOG_WARNING("[%s:%d] has no actionInfo\n", __FUNCTION__, __LINE__);
+ }
+
+ return ret;
+}
+
+static Eina_Bool _elm_access_read_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ bool ret = false;
+
+ if(ep)
+ {
+ PositionSize geometry = ep->GetEvasObjectGeometry();
+
+ if(actionInfo)
+ {
+ ret = ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_READ, actionInfo, (actionInfo->x - geometry.x), (actionInfo->y - geometry.y));
+ DALI_LOG_INFO(gEvasPluginLogFilter, Debug::General, "[%s:%d] returns %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+ }
+ else
+ {
+ DALI_LOG_WARNING( "[%s:%d] has no actionInfo\n", __FUNCTION__, __LINE__);
+ }
+ }
+
+ return ret;
+}
+
+static Eina_Bool _elm_access_over_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ bool ret = false;
+
+ if(ep)
+ {
+ PositionSize geometry = ep->GetEvasObjectGeometry();
+
+ if(actionInfo)
+ {
+ ret = ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_OVER, actionInfo, (actionInfo->x - geometry.x), (actionInfo->y - geometry.y));
+ DALI_LOG_INFO(gEvasPluginLogFilter, Debug::General, "[%s:%d] returns %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+ }
+ else
+ {
+ DALI_LOG_WARNING( "[%s:%d] has no actionInfo\n", __FUNCTION__, __LINE__);
+ }
+ }
+
+ return ret;
+}
+
+static Eina_Bool _elm_access_highlight_next_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_HIGHLIGHT_NEXT, actionInfo);
+}
+
+static Eina_Bool _elm_access_highlight_prev_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_HIGHLIGHT_PREV, actionInfo);
+}
+
+static Eina_Bool _elm_access_activate_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_ACTIVATE, actionInfo);
+}
+
+static Eina_Bool _elm_access_unhighlight_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_UNHIGHLIGHT, actionInfo);
+}
+
+static Eina_Bool _elm_access_back_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_BACK, actionInfo);
+}
+
+static Eina_Bool _elm_access_value_up_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_UP, actionInfo);
+}
+
+static Eina_Bool _elm_access_value_down_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_DOWN, actionInfo);
+}
+
+static Eina_Bool _elm_access_scroll_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ bool ret = false;
+
+ if(actionInfo && ep)
+ {
+ Evas_Coord rel_x, rel_y;
+ Evas_Coord obj_x, obj_y, obj_w, obj_h;
+ Evas_Object* eo = ep->GetEvasImageObject();
+
+ if(eo)
+ {
+ evas_object_geometry_get(eo, &obj_x, &obj_y, &obj_w, &obj_h);
+
+ rel_x = actionInfo->x - obj_x;
+ rel_y = actionInfo->y - obj_y;
+
+ ret = ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_SCROLL, actionInfo, rel_x, rel_y);
+ }
+ }
+ else
+ {
+ DALI_LOG_WARNING("[%s:%d] has no actionInfo\n", __FUNCTION__, __LINE__);
+ }
+
+ return ret;
+}
+
+static Eina_Bool _elm_access_mouse_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+ bool ret = false;
+
+ if(actionInfo && ep)
+ {
+ Evas_Coord rel_x, rel_y;
+ Evas_Coord obj_x, obj_y, obj_w, obj_h;
+ Evas_Object* eo = ep->GetEvasImageObject();
+
+ if(eo)
+ {
+ evas_object_geometry_get(eo, &obj_x, &obj_y, &obj_w, &obj_h);
+
+ rel_x = actionInfo->x - obj_x;
+ rel_y = actionInfo->y - obj_y;
+
+ ret = ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_MOUSE, actionInfo, rel_x, rel_y);
+ }
+ }
+ else
+ {
+ DALI_LOG_WARNING("[%s:%d] has no actionInfo\n", __FUNCTION__, __LINE__);
+ }
+
+ return ret;
+}
+
+static Eina_Bool _ecore_x_event_selection_clear(void *data, int type, void *event)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+
+ if( ep )
+ {
+ ep->OnEcoreEventSelectionCleared(data, type, event);
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool _ecore_x_event_selection_notify(void *data, int type, void *event)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+
+ if( ep )
+ {
+ ep->OnEcoreEventSelectionNotified(data, type, event);
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+static Eina_Bool _ecore_x_event_client_message(void* data, int type, void* event)
+{
+ EvasPlugin* ep = (EvasPlugin*)data;
+
+ if( ep )
+ {
+ ep->OnEcoreEventClientMessaged(data, type, event);
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+// Copied from x server
+static unsigned int GetCurrentMilliSeconds(void)
+{
+ struct timeval tv;
+
+ struct timespec tp;
+ static clockid_t clockid;
+
+ if (!clockid)
+ {
+#ifdef CLOCK_MONOTONIC_COARSE
+ if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
+ (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
+ {
+ clockid = CLOCK_MONOTONIC_COARSE;
+ }
+ else
+#endif
+ if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+ {
+ clockid = CLOCK_MONOTONIC;
+ }
+ else
+ {
+ clockid = ~0L;
+ }
+ }
+ if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
+ {
+ return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
+ }
+
+ gettimeofday(&tv, NULL);
+ return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
+}
+
+EvasPlugin::EvasPlugin(Dali::EvasPlugin& evasPlugin, Evas_Object* parent, bool isTransparent, unsigned int initialWidth, unsigned int initialHeight)
+: mEvasImageObject(NULL),
+ mElmAccessObject(NULL),
+ mElmFocusObject(NULL),
+ mSurface(NULL),
+ mFirstRenderCompleteNotified(false),
+ mEvasPlugin(evasPlugin),
+ mAdaptor(NULL),
+ mEvas(NULL),
+ mEvasImageObjectGeometry(0, 0, initialWidth, initialHeight),
+ mInitialized(false),
+ mIsTransparent(isTransparent),
+ mHasFocus(false),
+ mRenderNotification(NULL),
+ mEvasDirtyIdler(NULL)
+{
+ DALI_ASSERT_ALWAYS( parent && "No parent object for plugin" );
+ mEvas = AnyCast<Evas*>(evas_object_evas_get(parent));
+
+ /* create evas object image */
+ CreateEvasImageObject(mEvas, initialWidth, initialHeight, isTransparent);
+
+ /* create elm access object */
+ CreateElmAccessObject(parent);
+
+ /* create elm focus object */
+ CreateElmFocusObject(parent);
+
+ /* create adaptor */
+ CreateAdaptor(initialWidth, initialHeight);
+
+ /* render post callback */
+ evas_event_callback_add(mEvas, EVAS_CALLBACK_RENDER_POST, _evas_render_post_cb, this);
+
+ mRenderNotification = new TriggerEvent( boost::bind(&EvasPlugin::Render, this ) );
+
+ mSurface->SetRenderNotification( mRenderNotification );
+
+ mState = Ready;
+}
+
+EvasPlugin::~EvasPlugin()
+{
+ mConnectionTracker.DisconnectAll();
+
+ if (mAdaptor)
+ {
+ Stop();
+
+ // delete idler
+ ClearIdler();
+
+ // no more notifications
+ delete mRenderNotification;
+
+ // delete evas canvas callback for render sync
+ evas_event_callback_del(mEvas, EVAS_CALLBACK_RENDER_POST, _evas_render_post_cb);
+
+ delete mAdaptor;
+ mAdaptor = NULL;
+
+ // delete elm focus object
+ DeleteElmFocusObject();
+
+ // delete elm access object
+ DeleteElmAccessObject();
+
+ // delete evas object image
+ DeleteEvasImageObject();
+
+ if (mSurface)
+ {
+ delete mSurface;
+ mSurface = NULL;
+ }
+ }
+}
+
+void EvasPlugin::CreateEvasImageObject(Evas* evas, unsigned int initialWidth, unsigned int initialHeight, bool isTransparent)
+{
+ /* create evas object */
+
+ mEvasImageObject = evas_object_image_filled_add(mEvas);
+ evas_object_name_set(mEvasImageObject, "dali-evasplugin");
+ evas_object_image_content_hint_set(mEvasImageObject, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
+ evas_object_size_hint_align_set(mEvasImageObject, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(mEvasImageObject, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ if(isTransparent)
+ {
+ evas_object_image_alpha_set(mEvasImageObject, EINA_TRUE);
+ }
+
+ evas_object_move(mEvasImageObject, 0, 0);
+ evas_object_image_size_set(mEvasImageObject, initialWidth, initialHeight);
+ evas_object_resize(mEvasImageObject, initialWidth, initialHeight);
+
+ /* event callback */
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MOUSE_DOWN, _evas_object_mouse_down_cb, this);
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MOUSE_UP, _evas_object_mouse_up_cb, this);
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MOUSE_MOVE, _evas_object_mouse_move_cb, this);
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MOUSE_WHEEL, _evas_object_mouse_wheel_cb, this);
+
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MULTI_DOWN, _evas_object_multi_down_cb, this);
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MULTI_UP, _evas_object_multi_up_cb, this);
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MULTI_MOVE, _evas_object_multi_move_cb, this);
+
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_KEY_DOWN, _evas_object_key_down_cb, this);
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_KEY_UP, _evas_object_key_up_cb, this);
+
+ /* move callback */
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MOVE, _evas_object_move_cb, this);
+
+ /* resize callback */
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_RESIZE, _evas_object_resize_cb, this);
+
+ /* focus callback */
+ evas_event_callback_add(mEvas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _canvas_focus_in_cb, this);
+ evas_event_callback_add(mEvas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _canvas_focus_out_cb, this);
+
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_FOCUS_IN, _evas_object_focus_in_cb, this);
+ evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_FOCUS_OUT, _evas_object_focus_out_cb, this);
+
+ evas_object_show(mEvasImageObject);
+}
+
+void EvasPlugin::DeleteEvasImageObject()
+{
+ if(mEvasImageObject)
+ {
+ /* event callback */
+ evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MOUSE_DOWN, _evas_object_mouse_down_cb);
+ evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MOUSE_UP, _evas_object_mouse_up_cb);
+ evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MOUSE_MOVE, _evas_object_mouse_move_cb);
+
+ evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MULTI_DOWN, _evas_object_multi_down_cb);
+ evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MULTI_UP, _evas_object_multi_up_cb);
+ evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MULTI_MOVE, _evas_object_multi_move_cb);
+
+ evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_KEY_DOWN, _evas_object_key_down_cb);
+ evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_KEY_UP, _evas_object_key_up_cb);
+
+ /* move callback */
+ evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MOVE, _evas_object_move_cb);
+
+ /* resize callback */
+ evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_RESIZE, _evas_object_resize_cb);
+
+ /* focus callback */
+ evas_event_callback_del(mEvas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _canvas_focus_in_cb);
+ evas_event_callback_del(mEvas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _canvas_focus_out_cb);
+
+ evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_FOCUS_IN, _evas_object_focus_in_cb);
+ evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_FOCUS_OUT, _evas_object_focus_out_cb);
+
+ // evas object callbacks are deleted with the object
+ evas_object_del(mEvasImageObject);
+ mEvasImageObject = NULL;
+ }
+}
+
+void EvasPlugin::CreateElmAccessObject(Evas_Object* parent)
+{
+ // elm access register with image object
+ mElmAccessObject = elm_access_object_register(mEvasImageObject, parent);
+
+ // elm access action callbacks
+ elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_HIGHLIGHT, _elm_access_highlight_cb, this);
+ elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_UNHIGHLIGHT, _elm_access_unhighlight_cb, this);
+ elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_HIGHLIGHT_NEXT, _elm_access_highlight_next_cb, this);
+ elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_HIGHLIGHT_PREV, _elm_access_highlight_prev_cb, this);
+ elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_ACTIVATE, _elm_access_activate_cb, this);
+ elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_UP, _elm_access_value_up_cb, this);
+ elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_DOWN, _elm_access_value_down_cb, this);
+ elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_SCROLL, _elm_access_scroll_cb, this);
+ elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_MOUSE, _elm_access_mouse_cb, this);
+ elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_BACK, _elm_access_back_cb, this);
+ elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_READ, _elm_access_read_cb, this);
+ elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_OVER, _elm_access_over_cb, this);
+
+ /**
+ * Dali doesn't set the order of elm focus chain.
+ * Application should append mElmAccessObject to layout's custom focus chain
+ *
+ * e.g) elm_object_focus_custom_chain_append(parent, mElmAccessObject, NULL);
+ */
+}
+
+void EvasPlugin::DeleteElmAccessObject()
+{
+ if(mElmAccessObject)
+ {
+ // elm access action callbacks and elm_access_object will be deleted in unregister
+ elm_access_object_unregister(mEvasImageObject);
+ mElmAccessObject = NULL;
+ }
+}
+
+void EvasPlugin::CreateElmFocusObject(Evas_Object* parent)
+{
+ // create a button and set style as "focus", if does not want to show the focus, then "transparent"
+ mElmFocusObject = elm_button_add(parent);
+ // don't need to show the focus boundary here
+ elm_object_style_set(mElmFocusObject, "transparent");
+
+ // set the evas image object to focus object, but event should not be propagated
+ elm_object_part_content_set(mElmFocusObject, "elm.swallow.content", mEvasImageObject);
+ evas_object_propagate_events_set(mEvasImageObject, EINA_FALSE);
+
+ // set the evas object you want to make focusable as the content of the swallow part
+ evas_object_size_hint_weight_set(mElmFocusObject, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(mElmFocusObject, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ evas_object_smart_callback_add(mElmFocusObject, "focused", _elm_focus_object_focus_in_cb, this);
+ evas_object_smart_callback_add(mElmFocusObject, "unfocused", _elm_focus_object_focus_out_cb, this);
+
+ evas_object_show(mElmFocusObject);
+}
+
+void EvasPlugin::DeleteElmFocusObject()
+{
+ if(mElmFocusObject)
+ {
+ evas_object_smart_callback_del(mElmFocusObject, "focused", _elm_focus_object_focus_in_cb);
+ evas_object_smart_callback_del(mElmFocusObject, "unfocused", _elm_focus_object_focus_out_cb);
+
+ evas_object_del(mElmFocusObject);
+ mElmFocusObject = NULL;
+ }
+}
+
+void EvasPlugin::CreateAdaptor(unsigned int initialWidth, unsigned int initialHeight)
+{
+ mSurface = CreateSurface(initialWidth, initialHeight);
+
+ mAdaptor = Internal::Adaptor::Adaptor::New( mSurface, DeviceLayout::DEFAULT_BASE_LAYOUT );
+
+ Any surface = mSurface->GetSurface();
+
+ Ecore_X_Pixmap pixmap = AnyCast<Ecore_X_Pixmap>(surface);
+
+ /* set native pixmap surface */
+ Evas_Native_Surface ns;
+ ns.type = EVAS_NATIVE_SURFACE_X11;
+ ns.version = EVAS_NATIVE_SURFACE_VERSION;
+ ns.data.x11.pixmap = pixmap;
+ ns.data.x11.visual = NULL;
+
+ evas_object_image_native_surface_set(mEvasImageObject, &ns);
+}
+
+ECore::RenderSurface* EvasPlugin::CreateSurface( int width, int height )
+{
+ PositionSize pixmapSize( 0, 0, width, height );
+ Any surface;
+ Any display;
+ // if we already have surface, reuse its display
+ if( mSurface )
+ {
+ display = mSurface->GetMainDisplay();
+ }
+
+ // create a X11 pixmap
+ ECore::RenderSurface* daliSurface = ECore::CreatePixmapSurface( pixmapSize, surface, display, "no name", mIsTransparent );
+
+ daliSurface->SetRenderNotification( mRenderNotification );
+
+ return daliSurface;
+}
+
+void EvasPlugin::ResizeSurface()
+{
+ // remember old surface
+ Dali::RenderSurface* oldSurface = mSurface;
+ mSurface = CreateSurface( mEvasImageObjectGeometry.width, mEvasImageObjectGeometry.height );
+
+ // ask the replace the surface inside dali
+ Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface( *mSurface ); // this method is synchronous => guarantee until rendering next frame
+
+ // update the pixmap for evas
+ {
+ Any surface = mSurface->GetSurface();
+ Ecore_X_Pixmap pixmap = AnyCast<Ecore_X_Pixmap>( surface );
+
+ Evas_Native_Surface ns;
+ ns.type = EVAS_NATIVE_SURFACE_X11;
+ ns.version = EVAS_NATIVE_SURFACE_VERSION;
+ ns.data.x11.pixmap = pixmap;
+ ns.data.x11.visual = NULL;
+
+ evas_object_image_native_surface_set(mEvasImageObject, &ns);
+
+ // its now safe to delete the old surface
+ delete oldSurface;
+ }
+
+ OnResize();
+}
+
+void EvasPlugin::ConnectEcoreEvent()
+{
+ // Get Ecore_Evas using Evas.
+ Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get( mEvas );
+
+ if( ecoreEvas ) // Check invalid or valid.
+ {
+ // Get window from Ecore_Evas.
+ Ecore_X_Window window = ecore_evas_gl_x11_window_get( ecoreEvas );
+
+ // Set the application window at ime context.
+ Dali::ImfManager imfManager = Dali::ImfManager::Get();
+ Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
+ ecore_imf_context_client_window_set( imfContext, reinterpret_cast<void*>( window ) );
+
+ if( window ) // Check invalid or valid.
+ {
+ // Connect clipboard events.
+ mEcoreEventHandler.push_back( ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR, _ecore_x_event_selection_clear, this) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, _ecore_x_event_selection_notify, this) );
+
+ // Register Client message events - accessibility etc.
+ mEcoreEventHandler.push_back( ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _ecore_x_event_client_message, this) );
+ }
+ }
+}
+
+void EvasPlugin::DisconnectEcoreEvent()
+{
+ for( std::vector<Ecore_Event_Handler*>::iterator iter = mEcoreEventHandler.begin(), endIter = mEcoreEventHandler.end(); iter != endIter; ++iter )
+ {
+ ecore_event_handler_del( *iter );
+ }
+
+ mEcoreEventHandler.clear();
+}
+
+void EvasPlugin::Run()
+{
+ if(mState == Ready)
+ {
+ // Run the adaptor
+ mAdaptor->Start();
+ mState = Running;
+
+ OnInit();
+ }
+}
+
+void EvasPlugin::Pause()
+{
+ if(mState == Running)
+ {
+ mAdaptor->Pause();
+ mState = Suspended;
+
+ mPauseSignalV2.Emit( mEvasPlugin );
+ }
+}
+
+void EvasPlugin::Resume()
+{
+ if(mState == Suspended)
+ {
+ mAdaptor->Resume();
+ mState = Running;
+
+ mResumeSignalV2.Emit( mEvasPlugin );
+ }
+
+ // forcely dirty_set the evas_object on idle time
+ ClearIdler();
+ mEvasDirtyIdler = ecore_idler_add(_evas_object_dirty_set_idle_cb, this);
+}
+
+void EvasPlugin::ClearIdler(bool deleteHandle)
+{
+ if(mEvasDirtyIdler)
+ {
+ if(deleteHandle)
+ {
+ ecore_idler_del(mEvasDirtyIdler);
+ }
+ mEvasDirtyIdler = NULL;
+ }
+}
+
+void EvasPlugin::Stop()
+{
+ if(mState != Stopped)
+ {
+ // Stop the adaptor
+ mAdaptor->Stop();
+ mState = Stopped;
+
+ mTerminateSignalV2.Emit( mEvasPlugin );
+ }
+}
+Evas_Object* EvasPlugin::GetEvasImageObject()
+{
+ return mEvasImageObject;
+}
+
+Evas_Object* EvasPlugin::GetElmAccessObject()
+{
+ return mElmAccessObject;
+}
+
+Evas_Object* EvasPlugin::GetElmFocusObject()
+{
+ return mElmFocusObject;
+}
+
+void EvasPlugin::OnInit()
+{
+ mInitialized = true;
+
+ mInitSignalV2.Emit( mEvasPlugin );
+}
+
+void EvasPlugin::OnFirstRenderCompleted()
+{
+ mFirstRenderCompletedSignalV2.Emit( mEvasPlugin );
+
+ mFirstRenderCompleteNotified = true;
+}
+
+void EvasPlugin::Move()
+{
+ Evas_Coord x, y, w, h;
+ evas_object_geometry_get(mEvasImageObject, &x, &y, &w, &h);
+
+ // update geometry
+ mEvasImageObjectGeometry.x = x;
+ mEvasImageObjectGeometry.y = y;
+ mEvasImageObjectGeometry.width = w;
+ mEvasImageObjectGeometry.height = h;
+
+ DALI_LOG_INFO( gEvasPluginLogFilter, Debug::General, "EvasPlugin::Move : %d, %d, %d x %d\n", x, y, w, h );
+}
+
+void EvasPlugin::Resize()
+{
+ Evas_Coord x, y, w, h;
+ evas_object_geometry_get(mEvasImageObject, &x, &y, &w, &h);
+
+ // skip meaningless resize signal
+ if(w <= 1 || h <= 1)
+ {
+ return;
+ }
+
+ if(mEvasImageObjectGeometry.width == w && mEvasImageObjectGeometry.height == h)
+ {
+ return;
+ }
+
+ DALI_LOG_INFO( gEvasPluginLogFilter, Debug::General, "old size (%d x %d), new size (%d x %d)\n", mEvasImageObjectGeometry.width, mEvasImageObjectGeometry.height, w, h );
+
+ // update geometry
+ mEvasImageObjectGeometry.x = x;
+ mEvasImageObjectGeometry.y = y;
+ mEvasImageObjectGeometry.width = w;
+ mEvasImageObjectGeometry.height = h;
+
+ ResizeSurface();
+}
+
+void EvasPlugin::OnResize()
+{
+ if(mInitialized)
+ {
+ // emit resized signal to application
+ mResizeSignalV2.Emit( mEvasPlugin );
+ }
+}
+
+void EvasPlugin::Render()
+{
+ // dirty set while adaptor is running
+ if( EvasPlugin::Running == mState )
+ {
+ /* dirty set to post the result of rendering via evas */
+ evas_object_image_pixels_dirty_set( mEvasImageObject, EINA_TRUE );
+ }
+}
+
+void EvasPlugin::OnTouchEvent(TouchPoint& point, int timeStamp)
+{
+ if ( mAdaptor )
+ {
+ if(timeStamp < 1)
+ {
+ timeStamp = GetCurrentMilliSeconds();
+ }
+
+ Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).FeedTouchPoint( point, timeStamp );
+ }
+}
+
+void EvasPlugin::OnKeyEvent(KeyEvent& keyEvent)
+{
+ // Create KeyEvent and send to Core.
+ if ( mAdaptor )
+ {
+ Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).FeedKeyEvent( keyEvent );
+ }
+}
+
+void EvasPlugin::OnMouseWheelEvent(MouseWheelEvent& wheelEvent)
+{
+ if ( mAdaptor )
+ {
+ Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).FeedWheelEvent( wheelEvent );
+ }
+}
+
+void EvasPlugin::OnImfActivated(Dali::ImfManager& imfManager)
+{
+ // When imf is activated, set focus to own evas-object to get key events
+ evas_object_focus_set(mEvasImageObject, EINA_TRUE);
+}
+
+void EvasPlugin::RenderSync()
+{
+ if( NULL != mAdaptor )
+ {
+ Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).RenderSync();
+ }
+}
+
+bool EvasPlugin::OnAccessibilityActionEvent(Elm_Access_Action_Type actionType, Elm_Access_Action_Info* actionInfo, int x, int y)
+{
+ bool ret = false;
+
+ if( NULL == mAdaptor || NULL == actionInfo )
+ {
+ return ret;
+ }
+
+ Dali::AccessibilityManager accessibilityManager = Dali::AccessibilityManager::Get();
+ if( accessibilityManager )
+ {
+ int touchType = actionInfo->mouse_type;
+ int touchX = x >= 0 ? x : actionInfo->x;
+ int touchY = y >= 0 ? y : actionInfo->y;
+
+ switch(actionType)
+ {
+ case ELM_ACCESS_ACTION_HIGHLIGHT:
+ case ELM_ACCESS_ACTION_READ:
+ {
+ ret = accessibilityManager.HandleActionReadEvent((unsigned int)x, (unsigned int)y, true);
+ }
+ break;
+
+ case ELM_ACCESS_ACTION_OVER:
+ {
+ ret = accessibilityManager.HandleActionReadEvent((unsigned int)x, (unsigned int)y, false);
+ }
+ break;
+
+ case ELM_ACCESS_ACTION_HIGHLIGHT_PREV:
+ {
+ // if actionInfo->highlight_end is true, need to handle end_of_list sound feedback
+ ret = accessibilityManager.HandleActionPreviousEvent(actionInfo->highlight_end);
+ if(!ret)
+ {
+ // when focus moving was failed, clear the focus
+ accessibilityManager.HandleActionClearFocusEvent();
+ }
+ }
+ break;
+
+ case ELM_ACCESS_ACTION_HIGHLIGHT_NEXT:
+ {
+ // if actionInfo->highlight_end is true, need to handle end_of_list sound feedback
+ ret = accessibilityManager.HandleActionNextEvent(actionInfo->highlight_end);
+ if(!ret)
+ {
+ // when focus moving was failed, clear the focus
+ accessibilityManager.HandleActionClearFocusEvent();
+ }
+ }
+ break;
+
+ case ELM_ACCESS_ACTION_ACTIVATE:
+ {
+ ret = accessibilityManager.HandleActionActivateEvent();
+ }
+ break;
+
+ case ELM_ACCESS_ACTION_UNHIGHLIGHT:
+ {
+ ret = accessibilityManager.HandleActionClearFocusEvent();
+ }
+ break;
+
+ case ELM_ACCESS_ACTION_SCROLL:
+ {
+ TouchPoint::State state(TouchPoint::Down);
+
+ if (touchType == 0)
+ {
+ state = TouchPoint::Down; // mouse down
+ }
+ else if (touchType == 1)
+ {
+ state = TouchPoint::Motion; // mouse move
+ }
+ else if (touchType == 2)
+ {
+ state = TouchPoint::Up; // mouse up
+ }
+ else
+ {
+ state = TouchPoint::Interrupted; // error
+ }
+
+ // Send touch event to accessibility manager.
+ TouchPoint point( 0, state, (float)touchX, (float)touchY );
+ ret = accessibilityManager.HandleActionScrollEvent(point, GetCurrentMilliSeconds());
+ }
+ break;
+
+ case ELM_ACCESS_ACTION_UP:
+ {
+ ret = accessibilityManager.HandleActionUpEvent();
+ }
+ break;
+
+ case ELM_ACCESS_ACTION_DOWN:
+ {
+ ret = accessibilityManager.HandleActionDownEvent();
+ }
+ break;
+
+ case ELM_ACCESS_ACTION_MOUSE:
+ {
+ // generate normal mouse event
+ TouchPoint::State state(TouchPoint::Down);
+
+ if (touchType == 0)
+ {
+ state = TouchPoint::Down; // mouse down
+ }
+ else if (touchType == 1)
+ {
+ state = TouchPoint::Motion; // mouse move
+ }
+ else if (touchType == 2)
+ {
+ state = TouchPoint::Up; // mouse up
+ }
+ else
+ {
+ state = TouchPoint::Interrupted; // error
+ }
+
+ // Send touch event to accessibility manager.
+ TouchPoint point( 0, state, (float)touchX, (float)touchY );
+ ret = accessibilityManager.HandleActionTouchEvent(point, GetCurrentMilliSeconds());
+ }
+ break;
+
+ case ELM_ACCESS_ACTION_BACK:
+ default:
+ {
+ DALI_LOG_WARNING("[%s:%d]\n", __FUNCTION__, __LINE__);
+ }
+
+ break;
+ }
+ }
+ else
+ {
+ DALI_LOG_WARNING("[%s:%d]\n", __FUNCTION__, __LINE__);
+ }
+
+ DALI_LOG_INFO(gEvasPluginLogFilter, Debug::General, "[%s:%d] [action : %d] focus manager returns %s\n", __FUNCTION__, __LINE__, (int)(actionType), ret?"TRUE":"FALSE");
+
+ return ret;
+
+}
+
+void EvasPlugin::OnEvasObjectFocusedIn()
+{
+ if(mHasFocus)
+ {
+ return;
+ }
+ mHasFocus = true;
+
+ // If the evas object gains focus and we hide the keyboard then show it again.
+ if( Dali::Adaptor::IsAvailable() )
+ {
+ ConnectEcoreEvent();
+
+ Dali::ImfManager imfManager( Dali::ImfManager::Get() );
+ if( imfManager && imfManager.RestoreAfterFocusLost() )
+ {
+ imfManager.Activate();
+ }
+
+ // No need to connect callbacks as KeyboardStatusChanged will be called.
+
+ // emit focused signal to application
+ mFocusedSignalV2.Emit( mEvasPlugin );
+ }
+}
+
+void EvasPlugin::OnEvasObjectFocusedOut()
+{
+ if(!mHasFocus)
+ {
+ return;
+ }
+ mHasFocus = false;
+
+ // If the evas object loses focus then hide the keyboard.
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ Dali::ImfManager imfManager( Dali::ImfManager::Get() );
+ if( imfManager && imfManager.RestoreAfterFocusLost() )
+ {
+ imfManager.Deactivate();
+ }
+
+ // Clipboard don't support that whether clipboard is shown or not. Hide clipboard.
+ Dali::Clipboard clipboard = Dali::Clipboard::Get();
+ clipboard.HideClipboard();
+
+ DisconnectEcoreEvent();
+
+ // emit unfocused signal to application
+ mUnFocusedSignalV2.Emit( mEvasPlugin );
+ }
+}
+
+void EvasPlugin::OnEcoreEventSelectionCleared( void* data, int type, void* event )
+{
+ Ecore_X_Event_Selection_Clear* selectionClearEvent( (Ecore_X_Event_Selection_Clear*) event );
+
+ if( selectionClearEvent->selection == ECORE_X_SELECTION_SECONDARY )
+ {
+ // Request to get the content from Ecore.
+ ecore_x_selection_secondary_request(selectionClearEvent->win, ECORE_X_SELECTION_TARGET_TEXT);
+ }
+}
+
+void EvasPlugin::OnEcoreEventSelectionNotified(void* data, int type, void* event)
+{
+ Ecore_X_Event_Selection_Notify* selectionNotifyEvent( (Ecore_X_Event_Selection_Notify*) event );
+
+ if( selectionNotifyEvent->selection == ECORE_X_SELECTION_SECONDARY )
+ {
+ // We have got the selected content, inform the clipboard event listener (if we have one).
+ Dali::ClipboardEventNotifier clipboardEventNotifier = Dali::ClipboardEventNotifier::Get();
+ Ecore_X_Selection_Data* selectionData( (Ecore_X_Selection_Data*) selectionNotifyEvent->data );
+
+ if ( clipboardEventNotifier )
+ {
+ std::string content( (char*) selectionData->data, selectionData->length );
+
+ if( !content.empty() )
+ {
+ clipboardEventNotifier.SetContent( content );
+ clipboardEventNotifier.EmitContentSelectedSignal();
+ }
+ }
+
+ // Claim the ownership of the SECONDARY selection.
+ ecore_x_selection_secondary_set(selectionNotifyEvent->win, "", 1);
+ }
+}
+
+void EvasPlugin::OnEcoreEventClientMessaged(void* data, int type, void* event)
+{
+ Ecore_X_Event_Client_Message* clientMessageEvent( (Ecore_X_Event_Client_Message*)event );
+
+ if(clientMessageEvent->message_type == ecore_x_atom_get(CLIPBOARD_ATOM))
+ {
+ std::string message(clientMessageEvent->data.b);
+ if( message == CLIPBOARD_SET_OWNER_MESSAGE)
+ {
+ // Claim the ownership of the SECONDARY selection.
+ ecore_x_selection_secondary_set(clientMessageEvent->win, "", 1);
+
+ // Show the clipboard window
+ Dali::Clipboard clipboard = Dali::Clipboard::Get();
+ clipboard.ShowClipboard();
+ }
+ }
+}
+
+void EvasPlugin::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
+{
+ mConnectionTracker.SignalConnected( slotObserver, callback );
+}
+
+void EvasPlugin::SignalDisconnected( SlotObserver* signal, CallbackBase* callback )
+{
+ mConnectionTracker.SignalDisconnected( signal, callback );
+}
+
+std::size_t EvasPlugin::GetConnectionCount() const
+{
+ return mConnectionTracker.GetConnectionCount();
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_EVAS_PLUGIN_H__
+#define __DALI_INTERNAL_EVAS_PLUGIN_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/bind.hpp>
+#include <boost/function.hpp>
+#include <boost/thread.hpp>
+#include <cstdlib>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <Elementary.h>
+#include <Evas.h>
+#include <Ecore.h>
+#include <Ecore_X.h>
+#include <Ecore_Input.h>
+
+#include <dali/public-api/math/rect.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/key-event-integ.h>
+
+// INTERNAL INCLUDES
+#include <imf-manager.h>
+#include <evas-plugin.h>
+
+#include <virtual-keyboard-impl.h>
+#include <clipboard-impl.h>
+
+namespace Dali
+{
+
+class Adaptor;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class TriggerEvent;
+
+typedef Dali::Rect<int> PositionSize;
+
+namespace ECore
+{
+class RenderSurface;
+}
+
+/**
+ * Implementation of the EvasPlugin class.
+ */
+class EvasPlugin : public ConnectionTrackerInterface
+{
+public:
+
+ typedef Dali::EvasPlugin::EvasPluginSignalV2 EvasPluginSignalV2;
+
+ /**
+ * Constructor
+ * @param[in] evasPlugin The public instance of the EvasPlugin
+ * @param[in] parent A pointer of the parent object
+ * @param[in] isTransparent Whether the object is transparent or not
+ * @param[in] initialWidth width for canvas
+ * @param[in] initialHeight height for canvas
+ */
+ EvasPlugin(Dali::EvasPlugin& evasPlugin, Evas_Object* parent, bool isTransparent, unsigned int initialWidth, unsigned int initialHeight);
+
+ /**
+ * Destructor
+ */
+ virtual ~EvasPlugin();
+
+public:
+
+ /**
+ * @copydoc Dali::EvasPlugin::Start()
+ */
+ virtual void Run();
+
+ /**
+ * @copydoc Dali::EvasPlugin::Pause()
+ */
+ virtual void Pause();
+
+ /**
+ * @copydoc Dali::EvasPlugin::Resume()
+ */
+ virtual void Resume();
+
+ /**
+ * @copydoc Dali::EvasPlugin::Stop()
+ */
+ virtual void Stop();
+
+ /**
+ * @copydoc Dali::EvasPlugin::GetEvasImageObject()
+ */
+ Evas_Object* GetEvasImageObject();
+
+ /**
+ * @copydoc Dali::EvasPlugin::GetElmAccessObject()
+ */
+ Evas_Object* GetElmAccessObject();
+
+ /**
+ * @copydoc Dali::EvasPlugin::GetElmFocusObject()
+ */
+ Evas_Object* GetElmFocusObject();
+
+ /**
+ * @copydoc Dali::EvasPlugin::GetAdaptor()
+ */
+ Dali::Adaptor* GetAdaptor() { return mAdaptor;}
+
+public:
+
+ /**
+ * Called when the adaptor is initialised.
+ */
+ void OnInit();
+
+ /**
+ * Called to notify that Dali has started rendering and atleast one frame has been rendered
+ */
+ void OnFirstRenderCompleted();
+
+ /**
+ * Resize the surface, Called when evas_object_image resized
+ */
+ void Resize();
+
+ /**
+ * Move the surface, Called when evas_object_image moved
+ */
+ void Move();
+
+ /**
+ * Called when the rendering surface is resized
+ */
+ void OnResize();
+
+ /**
+ * Render the pixmap
+ */
+ void Render();
+
+ /**
+ * Called when the event dispatched in evas object area.
+ * @param[in] point touch point structure
+ * @param[in] timeStamp event timestamp, if it is less than 1, this function will generate current time stamp
+ */
+ void OnTouchEvent(TouchPoint& point, int timeStamp);
+
+ /**
+ * Called when the mouse wheel event dispatched in evas object area.
+ * @param[in] wheelEvent The mouse wheel event
+ */
+ void OnMouseWheelEvent( MouseWheelEvent& wheelEvent );
+
+ /**
+ * Called when the key event dispatched in evas object area.
+ * @param[in] keyEvent The key event.
+ */
+ void OnKeyEvent(KeyEvent& keyEvent);
+
+ /**
+ * Called when the accessibility action event dispatched from elm_access.
+ * @param[in] actionType elm accessibility action type structure
+ * @param[in] x x position for action, it could be unnecessary
+ * @param[in] y y position for action, it could be unnecessary
+ * @param[in] type mouse event type, it could be unnecessary
+ * @return True if the event was handled
+ */
+ bool OnAccessibilityActionEvent(Elm_Access_Action_Type actionType, Elm_Access_Action_Info* actionInfo, int x = -1, int y = -1);
+
+ /**
+ * Called when evqas object gain focus.
+ */
+ void OnEvasObjectFocusedIn();
+
+ /**
+ * Called when evas object lost focus
+ */
+ void OnEvasObjectFocusedOut();
+
+ /**
+ * Called when the source window notifies us the content in clipboard is selected.
+ * @param[in] data A data pointer.
+ * @param[in] type A type of event.
+ * @param[in] event A event information pointer.
+ */
+ void OnEcoreEventSelectionCleared(void* data, int type, void* event);
+
+ /**
+ * Called when the source window sends us about the selected content.
+ * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
+ * @param[in] data A data pointer.
+ * @param[in] type A type of event.
+ * @param[in] event A event information pointer.
+ */
+ void OnEcoreEventSelectionNotified(void* data, int type, void* event);
+
+ /**
+ * Called when the client messages (i.e. the accessibility events) are received.
+ * @param[in] data A data pointer.
+ * @param[in] type A type of event.
+ * @param[in] event A event information pointer.
+ */
+ void OnEcoreEventClientMessaged(void* data, int type, void* event);
+
+ /**
+ * Called when the result of rendering was posted to on-screen.
+ * Adaptor (i.e. render thread) can be waiting this sync to render next frame.
+ */
+ void RenderSync();
+
+ /**
+ * It returns geometry information of evas-object
+ * @return geometry information of evas-object
+ */
+ PositionSize GetEvasObjectGeometry() const { return mEvasImageObjectGeometry; }
+
+ /**
+ * Clear ecore idler handler
+ * @param[in] deleteHandle false if it does not need to delete the idler handle
+ * (e.g. when idler callback returns ECORE_CALLBACK_CANCEL, handler will be deleted automatically)
+ */
+ void ClearIdler(bool deleteHandle = true);
+
+ /**
+ * @copydoc ConnectionTrackerInterface::SignalConnected
+ */
+ virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback );
+
+ /**
+ * @copydoc ConnectionTrackerInterface::SignalDisconnected
+ */
+ virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback );
+
+ /**
+ * @copydoc ConnectionTrackerInterface::GetConnectionCount
+ */
+ virtual std::size_t GetConnectionCount() const;
+
+public: // Signals
+
+ /**
+ * @copydoc Dali::EvasPlugin::InitSignal()
+ */
+ EvasPluginSignalV2& InitSignal() { return mInitSignalV2; }
+
+ /**
+ * @copydoc Dali::EvasPlugin::FirstRenderCompletedSignal()
+ */
+ EvasPluginSignalV2& FirstRenderCompletedSignal() { return mFirstRenderCompletedSignalV2; }
+
+ /**
+ * @copydoc Dali::EvasPlugin::TerminateSignal()
+ */
+ EvasPluginSignalV2& TerminateSignal() { return mTerminateSignalV2; }
+
+ /**
+ * @copydoc Dali::EvasPlugin::PauseSignal()
+ */
+ EvasPluginSignalV2& PauseSignal() { return mPauseSignalV2; }
+
+ /**
+ * @copydoc Dali::EvasPlugin::ResumeSignal()
+ */
+ EvasPluginSignalV2& ResumeSignal() { return mResumeSignalV2; }
+
+ /**
+ * @copydoc Dali::EvasPlugin::ResizeSignal()
+ */
+ EvasPluginSignalV2& ResizeSignal() { return mResizeSignalV2; }
+
+ /**
+ * @copydoc Dali::EvasPlugin::FocusedSignal()
+ */
+ EvasPluginSignalV2& FocusedSignal() { return mFocusedSignalV2; }
+
+ /**
+ * @copydoc Dali::EvasPlugin::UnFocusedSignal()
+ */
+ EvasPluginSignalV2& UnFocusedSignal() { return mUnFocusedSignalV2; }
+
+private:
+
+ // Undefined
+ EvasPlugin(const EvasPlugin&);
+ EvasPlugin& operator=(EvasPlugin&);
+
+private:
+
+ /**
+ * Create / Delete the evas image object
+ */
+ void CreateEvasImageObject(Evas* evas, unsigned int initialWidth, unsigned int initialHeight, bool isTransparent);
+ void DeleteEvasImageObject();
+
+ /**
+ * Create / Delete the elm access object
+ */
+ void CreateElmAccessObject(Evas_Object* parent);
+ void DeleteElmAccessObject();
+
+ /**
+ * Create / Delete the elm focus object
+ */
+ void CreateElmFocusObject(Evas_Object* parent);
+ void DeleteElmFocusObject();
+
+ /**
+ * Creates the adaptor
+ */
+ void CreateAdaptor(unsigned int initialWidth, unsigned int initialHeight);
+
+ /**
+ * Creates the render surface
+ * @param width of the surface
+ * @param height of the surface
+ * @return the new surface
+ */
+ ECore::RenderSurface* CreateSurface( int width, int height );
+
+ /**
+ * Resize the surface
+ * To resize, create new surface with evas object's size and replace with it.
+ */
+ void ResizeSurface();
+
+ /**
+ * Connect ecore event if the evas plugin has Ecore_X_Window.
+ */
+ void ConnectEcoreEvent();
+
+ /**
+ * Disconnect all connected event.
+ */
+ void DisconnectEcoreEvent();
+
+ /**
+ * For ImfActivated signal
+ * When the imf is activated, it will handle the focus
+ * @param[in] imfManager imfManager instance
+ */
+ void OnImfActivated(Dali::ImfManager& imfManager);
+
+public:
+ enum State
+ {
+ Ready,
+ Running,
+ Suspended,
+ Stopped,
+ };
+
+ State mState;
+
+public:
+ /* for rendering control : these public members will be used in static function */
+ Evas_Object* mEvasImageObject;
+ Evas_Object* mElmAccessObject;
+ Evas_Object* mElmFocusObject;
+ ECore::RenderSurface* mSurface;
+ bool mFirstRenderCompleteNotified;
+
+private:
+
+ EvasPluginSignalV2 mInitSignalV2;
+ EvasPluginSignalV2 mFirstRenderCompletedSignalV2;
+ EvasPluginSignalV2 mTerminateSignalV2;
+ EvasPluginSignalV2 mPauseSignalV2;
+ EvasPluginSignalV2 mResumeSignalV2;
+ EvasPluginSignalV2 mResizeSignalV2;
+ EvasPluginSignalV2 mFocusedSignalV2;
+ EvasPluginSignalV2 mUnFocusedSignalV2;
+
+ Dali::EvasPlugin& mEvasPlugin;
+
+ Dali::Adaptor* mAdaptor;
+
+ Evas* mEvas;
+ PositionSize mEvasImageObjectGeometry;
+
+ bool mInitialized;
+ bool mIsTransparent;
+ bool mHasFocus;
+ TriggerEvent* mRenderNotification; ///< Render Notification trigger
+
+ Ecore_Idler * mEvasDirtyIdler; ///< Ecore idler for updating image object when it resumed
+
+ std::vector<Ecore_Event_Handler*> mEcoreEventHandler; ///< Vector of Ecore_Event_Handler
+
+ Dali::ConnectionTracker mConnectionTracker; ///< Used to implement ConnectionTrackerInterface
+
+public:
+ inline static EvasPlugin& GetImplementation(Dali::EvasPlugin& evasPlugin) { return *evasPlugin.mImpl; }
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_EVAS_PLUGIN_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <public-api/evas-plugin.h>
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+#include <mobile/evas-plugin-impl.h>
+
+namespace Dali
+{
+
+EvasPlugin::EvasPlugin(Evas_Object* parent, bool isTransparent, unsigned int initialWidth, unsigned int initialHeight)
+{
+ mImpl = new Internal::Adaptor::EvasPlugin(*this, parent, isTransparent, initialWidth, initialHeight);
+}
+
+EvasPlugin::~EvasPlugin()
+{
+ delete mImpl;
+}
+
+void EvasPlugin::Run()
+{
+ mImpl->Run();
+}
+
+void EvasPlugin::Pause()
+{
+ mImpl->Pause();
+}
+
+void EvasPlugin::Resume()
+{
+ mImpl->Resume();
+}
+
+void EvasPlugin::Stop()
+{
+ mImpl->Stop();
+}
+
+Evas_Object* EvasPlugin::GetEvasImageObject()
+{
+ return mImpl->GetEvasImageObject();
+}
+
+Evas_Object* EvasPlugin::GetElmAccessObject()
+{
+ return mImpl->GetElmAccessObject();
+}
+
+Evas_Object* EvasPlugin::GetElmFocusObject()
+{
+ return mImpl->GetElmFocusObject();
+}
+
+Dali::Adaptor* EvasPlugin::GetAdaptor()
+{
+ return mImpl->GetAdaptor();
+}
+
+EvasPlugin::EvasPluginSignalV2& EvasPlugin::InitSignal()
+{
+ return mImpl->InitSignal();
+}
+
+EvasPlugin::EvasPluginSignalV2& EvasPlugin::FirstRenderCompletedSignal()
+{
+ return mImpl->FirstRenderCompletedSignal();
+}
+
+EvasPlugin::EvasPluginSignalV2& EvasPlugin::TerminateSignal()
+{
+ return mImpl->TerminateSignal();
+}
+
+EvasPlugin::EvasPluginSignalV2& EvasPlugin::PauseSignal()
+{
+ return mImpl->PauseSignal();
+}
+
+EvasPlugin::EvasPluginSignalV2& EvasPlugin::ResumeSignal()
+{
+ return mImpl->ResumeSignal();
+}
+
+EvasPlugin::EvasPluginSignalV2& EvasPlugin::ResizeSignal()
+{
+ return mImpl->ResizeSignal();
+}
+
+EvasPlugin::EvasPluginSignalV2& EvasPlugin::FocusedSignal()
+{
+ return mImpl->FocusedSignal();
+}
+
+EvasPlugin::EvasPluginSignalV2& EvasPlugin::UnFocusedSignal()
+{
+ return mImpl->UnFocusedSignal();
+}
+
+/**
+ * @copydoc ConnectionTrackerInterface::SignalConnected
+ */
+void EvasPlugin::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
+{
+ mImpl->SignalConnected(slotObserver, callback );
+}
+
+/**
+ * @copydoc ConnectionTrackerInterface::SignalDisconnected
+ */
+void EvasPlugin::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
+{
+ mImpl->SignalDisconnected(slotObserver, callback );
+}
+
+/**
+ * @copydoc ConnectionTrackerInterface::GetConnectionCount
+ */
+std::size_t EvasPlugin::GetConnectionCount() const
+{
+ return mImpl->GetConnectionCount( );
+}
+
+} // namespace Dali
--- /dev/null
+# mobile profile internal files
+adaptor_common_internal_src_files += \
+ $(adaptor_common_dir)/../mobile/mobile-render-surface-factory.cpp \
+ $(adaptor_common_dir)/../mobile/mobile-native-buffer-render-surface.cpp \
+ $(adaptor_common_dir)/../mobile/mobile-system-settings.cpp \
+ $(adaptor_common_dir)/../mobile/mobile-color-controller-impl.cpp
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <common/color-controller-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+#include <efl_assist_theme.h>
+
+// INTERNAL INCLUDES
+#include <common/adaptor-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+BaseHandle Create()
+{
+ return ColorController::Get();
+}
+Dali::TypeRegistration COLOR_CONTROLLER_TYPE( typeid(Dali::ColorController), typeid(Dali::BaseHandle), Create );
+
+}
+
+Dali::ColorController ColorController::Get()
+{
+ Dali::ColorController colorController;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::ColorController ) );
+ if(handle)
+ {
+ // If so, downcast the handle
+ colorController = Dali::ColorController( dynamic_cast< ColorController* >( handle.GetObjectPtr() ) );
+ }
+ else
+ {
+ Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
+ colorController = Dali::ColorController( new ColorController( ) );
+ adaptorImpl.RegisterSingleton( typeid( colorController ), colorController );
+ }
+ }
+
+ return colorController;
+
+}
+
+ColorController::ColorController()
+{
+}
+
+ColorController::~ColorController()
+{
+}
+
+bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
+{
+ int R = 0;
+ int G = 0;
+ int B = 0;
+ int A = 0;
+
+ if( ea_theme_color_get(colorCode.c_str(), &R, &G, &B, &A, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) )
+ {
+ colorValue.r = (float) (R) / 255.0f;
+ colorValue.g = (float) (G) / 255.0f;
+ colorValue.b = (float) (B) / 255.0f;
+ colorValue.a = (float) (A) / 255.0f;
+
+ return true;
+ }
+
+ return false;
+}
+
+bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
+{
+ int R = 0;
+ int G = 0;
+ int B = 0;
+ int A = 0;
+
+ int outlineR = 0;
+ int outlineG = 0;
+ int outlineB = 0;
+ int outlineA = 0;
+
+ int shadowR = 0;
+ int shadowG = 0;
+ int shadowB = 0;
+ int shadowA = 0;
+
+ if( ea_theme_color_get(colorCode.c_str(), &R, &G, &B, &A, &outlineR, &outlineG, &outlineB, &outlineA, &shadowR, &shadowG, &shadowB, &shadowA) )
+ {
+ textColor.r = (float) (R) / 255.0f;
+ textColor.g = (float) (G) / 255.0f;
+ textColor.b = (float) (B) / 255.0f;
+ textColor.a = (float) (A) / 255.0f;
+
+ textOutlineColor.r = (float) (outlineR) / 255.0f;
+ textOutlineColor.g = (float) (outlineG) / 255.0f;
+ textOutlineColor.b = (float) (outlineB) / 255.0f;
+ textOutlineColor.a = (float) (outlineA) / 255.0f;
+
+ textShadowColor.r = (float) (shadowR) / 255.0f;
+ textShadowColor.g = (float) (shadowG) / 255.0f;
+ textShadowColor.b = (float) (shadowB) / 255.0f;
+ textShadowColor.a = (float) (shadowA) / 255.0f;
+
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "mobile-native-buffer-render-surface.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/gl-abstraction.h>
+#include <native-buffer-pool.h>
+
+// INTERANL INCLUDES
+#include <gl/egl-implementation.h>
+#include <trigger-event.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+#if defined(DEBUG_ENABLED)
+extern Debug::Filter* gRenderSurfaceLogFilter;
+#endif
+
+namespace ECore
+{
+
+NativeBufferRenderSurface::NativeBufferRenderSurface( native_buffer_provider* provider,
+ native_buffer_pool* pool,
+ unsigned int maxBufferCount,
+ Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent )
+: RenderSurface( Dali::RenderSurface::NATIVE_BUFFER, positionSize, surface, display, "native_buffer", isTransparent ),
+ mProvider( provider ),
+ mPool( pool ),
+ mMaxBufferCount( maxBufferCount ),
+ mIsAcquired( false )
+{
+ DALI_ASSERT_ALWAYS(maxBufferCount > 0);
+ Init( surface );
+}
+
+NativeBufferRenderSurface::~NativeBufferRenderSurface()
+{
+ DALI_LOG_WARNING("%d native buffer will be destroyed\n", mBuffers.size());
+
+ // destroy buffers
+ NativeBufferContainer::iterator bufferIter;
+ for (bufferIter = mBuffers.begin(); bufferIter != mBuffers.end(); ++bufferIter)
+ {
+ native_buffer_destroy((*bufferIter));
+ }
+ mBuffers.clear();
+}
+
+Ecore_X_Drawable NativeBufferRenderSurface::GetDrawable()
+{
+ return (Ecore_X_Drawable)0;
+}
+
+Dali::RenderSurface::SurfaceType NativeBufferRenderSurface::GetType()
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+ return Dali::RenderSurface::NATIVE_BUFFER;
+}
+
+Any NativeBufferRenderSurface::GetSurface()
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+ return Any();
+}
+
+void NativeBufferRenderSurface::InitializeEgl( EglInterface& egl )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );
+ eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ), false /* external surface */);
+
+ eglImpl.ChooseConfig(false, mColorDepth);
+}
+
+native_buffer* NativeBufferRenderSurface::CreateNativeBuffer()
+{
+ native_buffer* buffer;
+
+ buffer = native_buffer_create(mProvider, mPosition.width, mPosition.height,
+ mColorDepth == COLOR_DEPTH_32? mPosition.width * 4 : mPosition.width * 3, /* stride will be deprecated */
+ mColorDepth == COLOR_DEPTH_32? NATIVE_BUFFER_FORMAT_BGRA_8888 : NATIVE_BUFFER_FORMAT_RGB_888,
+ NATIVE_BUFFER_USAGE_3D_RENDER);
+
+ if(buffer)
+ {
+ // insert buffer to list
+ mBuffers.push_back(buffer);
+ }
+
+ return buffer;
+}
+
+void NativeBufferRenderSurface::CreateEglSurface( EglInterface& egl )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );
+
+ // create one buffer
+ native_buffer_pool_add_buffer(mPool, CreateNativeBuffer());
+
+ DALI_ASSERT_ALWAYS( native_buffer_pool_acquire_surface( mPool, eglImpl.GetDisplay(), eglImpl.GetContext() ) == STATUS_SUCCESS );
+ mIsAcquired = true;
+}
+
+void NativeBufferRenderSurface::DestroyEglSurface( EglInterface& egl )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ // Remove buffers from pool
+ native_buffer_pool_reset(mPool);
+}
+
+bool NativeBufferRenderSurface::ReplaceEGLSurface( EglInterface& egl )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ return false;
+}
+
+bool NativeBufferRenderSurface::PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction )
+{
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );
+
+ if(mIsAcquired)
+ {
+ mIsAcquired = false;
+ return true;
+ }
+
+ // Attempt to acquire a surface for rendering
+ while( !mIsStopped && native_buffer_pool_get_input_buffer_count(mPool) < 1 )
+ {
+ if(mBuffers.size() <= mMaxBufferCount)
+ {
+ // create one buffer
+ native_buffer_pool_add_buffer(mPool, CreateNativeBuffer());
+ }
+ else
+ {
+ usleep( 5 * 1000 ); // polling per 5 msec
+ }
+ }
+
+ if( !mIsStopped && native_buffer_pool_acquire_surface( mPool, eglImpl.GetDisplay(), eglImpl.GetContext() ) != STATUS_SUCCESS )
+ {
+ DALI_LOG_ERROR("Failed to acquire native buffer surface (# queue : %d)\n", native_buffer_pool_get_input_buffer_count(mPool));
+ }
+
+ return !mIsStopped; // fail if it is stopped
+}
+
+void NativeBufferRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode )
+{
+ glAbstraction.Flush();
+
+ // release the surface to allow consumer usage
+ if(native_buffer_pool_release_surface( mPool ) != STATUS_SUCCESS)
+ {
+ DALI_LOG_ERROR("Failed to release native buffer surface (# queue : %d)\n", native_buffer_pool_get_input_buffer_count(mPool));
+ }
+
+ // create damage for client applications which wish to know the update timing
+ if( mRenderNotification )
+ {
+ // use notification trigger
+ // Tell the event-thread to render the pixmap
+ mRenderNotification->Trigger();
+ }
+
+ // Do render synchronisation
+ DoRenderSync( timeDelta, syncMode );
+}
+
+void NativeBufferRenderSurface::CreateXRenderable()
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ // nothing to do
+}
+
+void NativeBufferRenderSurface::UseExistingRenderable( unsigned int surfaceId )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ // nothing to do
+}
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_NATIVE_BUFFER_RENDER_SURFACE_H__
+#define __DALI_INTERNAL_NATIVE_BUFFER_RENDER_SURFACE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <native-buffer-pool.h>
+#include <dali/public-api/common/vector-wrapper.h>
+
+// INTERNAL INCLUDES
+#include <ecore-x-render-surface.h>
+
+using namespace std;
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECore
+{
+
+/**
+ * NativeBuffer API compatible implementation of RenderSurface.
+ */
+class NativeBufferRenderSurface : public RenderSurface
+{
+public:
+
+ /**
+ * Constructor
+ */
+ NativeBufferRenderSurface( native_buffer_provider* provider,
+ native_buffer_pool* pool,
+ unsigned int maxBufferCount,
+ Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent );
+
+ /**
+ * Destructor
+ */
+ virtual ~NativeBufferRenderSurface();
+
+public: // API
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface::GetDrawable()
+ */
+ virtual Ecore_X_Drawable GetDrawable();
+
+public: // from Dali::RenderSurface
+
+ /**
+ * @copydoc Dali::RenderSurface::GetType()
+ */
+ virtual Dali::RenderSurface::SurfaceType GetType();
+
+ /**
+ * @copydoc Dali::RenderSurface::GetSurface()
+ */
+ virtual Any GetSurface();
+
+public: // from Internal::Adaptor::RenderSurface
+
+ /// @copydoc Dali::Internal::Adaptor::RenderSurface::InitializeEgl
+ virtual void InitializeEgl( EglInterface& egl );
+
+ /// @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface
+ virtual void CreateEglSurface( EglInterface& egl );
+
+ /// @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface
+ virtual void DestroyEglSurface( EglInterface& egl );
+
+ /// @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface
+ virtual bool ReplaceEGLSurface( EglInterface& egl );
+
+ /// @copydoc Dali::RenderSurface::PreRender
+ virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction );
+
+ /// @copydoc Dali::RenderSurface::PostRender
+ virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode );
+
+protected:
+
+ /**
+ * Create XWindow
+ */
+ virtual void CreateXRenderable();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface::UseExistingRenderable
+ */
+ virtual void UseExistingRenderable( unsigned int surfaceId );
+
+private:
+ /**
+ * Create native buffer
+ */
+ native_buffer* CreateNativeBuffer();
+
+private: // Data
+ native_buffer_provider* mProvider;
+ native_buffer_pool* mPool;
+
+ typedef std::vector<native_buffer*> NativeBufferContainer;
+ NativeBufferContainer mBuffers;
+
+ unsigned int mMaxBufferCount;
+ bool mIsAcquired;
+}; // class NativeBufferRenderSurface
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_NATIVE_BUFFER_RENDER_SURFACE_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <pixmap-render-surface.h>
+#include "mobile-native-buffer-render-surface.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECore
+{
+
+DALI_EXPORT_API RenderSurface* CreatePixmapSurface(
+ PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent )
+{
+ return new PixmapRenderSurface( positionSize, surface, display, name, isTransparent );
+}
+
+DALI_EXPORT_API RenderSurface* CreateNativeBufferSurface(
+ native_buffer_provider* provider,
+ native_buffer_pool* pool,
+ unsigned int maxBufferCount,
+ PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent )
+{
+ return new NativeBufferRenderSurface( provider, pool, maxBufferCount, positionSize,
+ surface, display, name, isTransparent);
+}
+
+} // namespace ECoreX
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+
+
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_MOBILE_RENDER_SURFACE_FACTORY_H__
+#define __DALI_INTERNAL_ADAPTOR_MOBILE_RENDER_SURFACE_FACTORY_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/any.hpp>
+#include <string>
+#include <dali/public-api/math/rect.h>
+#include <dali/public-api/common/dali-common.h>
+
+// INTERNAL INCLUDES
+#include <native-buffer-pool.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECore
+{
+
+class RenderSurface;
+
+/**
+ * Surface factory function for pixmap
+ * A pixmap surface is created.
+ *
+ * @param [in] type the type of surface to create
+ * @param [in] positionSize the position and size of the surface to create
+ * @param [in] display X Pixmap to use, or null for default.
+ * @param [in] display X Display to use, or null for default.
+ * @param [in] name Name of surface passed in
+ * @param [in] isTransparent Whether the surface has an alpha channel
+ */
+DALI_IMPORT_API RenderSurface* CreatePixmapSurface(
+ PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent );
+
+/**
+ * Surface factory function for Native buffer
+ * A native buffer surface is created.
+ * @param [in] provider The provider
+ * @param [in] pool The native buffer pool
+ * @param [in] maxBufferCount The maximum number of buffers to create
+ * @param [in] type the type of surface to create
+ * @param [in] positionSize the position and size of the surface to create
+ * @param [in] display X Pixmap to use, or null for default.
+ * @param [in] display X Display to use, or null for default.
+ * @param [in] name Name of surface passed in
+ * @param [in] isTransparent Whether the surface has an alpha channel
+ */
+DALI_IMPORT_API RenderSurface* CreateNativeBufferSurface(
+ native_buffer_provider* provider,
+ native_buffer_pool* pool,
+ unsigned int maxBufferCount,
+ PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent );
+
+} // namespace ECoreX
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ADAPTOR_MOBILE_RENDER_SURFACE_FACTORY_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <system_settings.h>
+#include <Elementary.h>
+
+// INTERNAL INCLUDES
+#include <system-settings.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+int GetLongPressTime( int defaultTime )
+{
+ int delay( 0 );
+
+ // read system setting
+ if( SYSTEM_SETTINGS_ERROR_NONE != system_settings_get_value_int(SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, &delay ) )
+ {
+ // on error, return default
+ delay = defaultTime;
+ }
+
+ return delay;
+}
+
+int GetElmAccessActionOver()
+{
+ return ELM_ACCESS_ACTION_OVER;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "native-buffer-plugin-impl.h"
+
+// EXTERNAL HEADERS
+#include <Ecore_X.h>
+
+#include <dali/public-api/dali-core.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL HEADERS
+#include <accessibility-manager-impl.h>
+#include <adaptor-impl.h>
+#include "mobile-render-surface-factory.h"
+#include <ecore-x-render-surface.h>
+#include <trigger-event.h>
+
+namespace Dali
+{
+
+namespace SlpPlatform
+{
+
+class SlpPlatformAbstraction;
+
+} // namespace SlpPlatform
+
+namespace Integration
+{
+
+class Core;
+
+} // namespace Integration
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+#if defined(DEBUG_ENABLED)
+Integration::Log::Filter* gLogFilter = Integration::Log::Filter::New(Debug::Verbose, true, "LOG_NATIVE_BUFFER_PLUGIN");
+#endif
+
+} // namespace
+
+NativeBufferPlugin::NativeBufferPlugin(Dali::NativeBufferPlugin& nbPlugin, unsigned int initialWidth, unsigned int initialHeight, bool isTransparent, unsigned int maxBufferCount, Dali::RenderSurface::RenderMode mode, const DeviceLayout& baseLayout )
+: mNativeBufferPlugin( nbPlugin ),
+ mAdaptor( NULL ),
+ mSurface( NULL ),
+ mRenderNotification( NULL ),
+ mState( Stopped ),
+ mInitialized( false ),
+ mFirstRenderCompleteNotified( false )
+{
+ // create provider
+ mProvider = native_buffer_provider_create(NATIVE_BUFFER_PROVIDER_CORE);
+
+ //create pool
+ mPool = native_buffer_pool_create( mProvider );
+
+ // create surface
+ mSurface = CreateSurface( initialWidth, initialHeight, isTransparent, maxBufferCount );
+
+ // create adaptor
+ CreateAdaptor( *mSurface, baseLayout );
+
+ // render notification
+ mRenderNotification = new TriggerEvent( boost::bind(&NativeBufferPlugin::OnRender, this ) );
+ mSurface->SetRenderNotification( mRenderNotification );
+ mSurface->SetRenderMode(mode);
+
+ mState = Ready;
+}
+
+NativeBufferPlugin::~NativeBufferPlugin()
+{
+ if( mAdaptor )
+ {
+ Stop();
+
+ // no more notifications
+ delete mRenderNotification;
+
+ delete mAdaptor;
+ delete mSurface;
+
+ native_buffer_pool_destroy(mPool);
+ native_buffer_provider_destroy(mProvider);
+ }
+}
+
+void NativeBufferPlugin::CreateAdaptor( ECore::RenderSurface &surface, const DeviceLayout& baseLayout )
+{
+ DALI_LOG_TRACE_METHOD( gLogFilter );
+
+ mAdaptor = Internal::Adaptor::Adaptor::New( &surface, baseLayout );
+}
+
+ECore::RenderSurface* NativeBufferPlugin::CreateSurface( int width, int height, bool isTransparent, unsigned int maxBufferCount )
+{
+ DALI_LOG_TRACE_METHOD( gLogFilter );
+
+ PositionSize positionSize( 0, 0, width, height );
+ Any surface;
+ Any display;
+
+ // if we already have surface, reuse its display
+ if( mSurface )
+ {
+ display = mSurface->GetMainDisplay();
+ }
+
+ ECore::RenderSurface* nbSurface = ECore::CreateNativeBufferSurface( mProvider, mPool, maxBufferCount, positionSize, surface, display, "no name", isTransparent );
+
+ return nbSurface;
+}
+
+void NativeBufferPlugin::ChangeSurfaceSize(unsigned int width, unsigned int height)
+{
+ // TODO: not yet implemented
+ DALI_LOG_WARNING("Not yet implemented!\n");
+}
+
+Vector2 NativeBufferPlugin::GetBufferCount()
+{
+ Vector2 retVal;
+ retVal.x = native_buffer_pool_get_input_buffer_count(mPool);
+ retVal.y = native_buffer_pool_get_output_buffer_count(mPool);
+
+ return retVal;
+}
+
+void NativeBufferPlugin::Run()
+{
+ DALI_LOG_TRACE_METHOD( gLogFilter );
+
+ if(mState == Ready)
+ {
+ // Run the adaptor
+ mAdaptor->Start();
+ mState = Running;
+
+ OnInit();
+ }
+}
+
+void NativeBufferPlugin::Pause()
+{
+ DALI_LOG_TRACE_METHOD( gLogFilter );
+
+ if(mState == Running)
+ {
+ mAdaptor->Pause();
+ mState = Suspended;
+
+ mPauseSignalV2.Emit( mNativeBufferPlugin );
+ }
+}
+
+void NativeBufferPlugin::Resume()
+{
+ DALI_LOG_TRACE_METHOD( gLogFilter );
+
+ if(mState == Suspended)
+ {
+ mAdaptor->Resume();
+ mState = Running;
+
+ mResumeSignalV2.Emit( mNativeBufferPlugin );
+ }
+}
+
+void NativeBufferPlugin::Stop()
+{
+ DALI_LOG_TRACE_METHOD( gLogFilter );
+
+ if(mState != Stopped)
+ {
+ // Stop the adaptor
+ mAdaptor->Stop();
+ mState = Stopped;
+
+ mTerminateSignalV2.Emit( mNativeBufferPlugin );
+ }
+}
+
+void NativeBufferPlugin::OnInit()
+{
+ DALI_LOG_TRACE_METHOD( gLogFilter );
+
+ mInitialized = true;
+ mInitSignalV2.Emit( mNativeBufferPlugin );
+}
+
+/*
+ * app can poll the get buffer after first rendered signal
+ * Otherwise, app can get render signal whenever it rendered
+ */
+void NativeBufferPlugin::OnFirstRenderCompleted()
+{
+ DALI_LOG_TRACE_METHOD( gLogFilter );
+
+ mFirstRenderCompletedSignalV2.Emit( mNativeBufferPlugin );
+ mFirstRenderCompleteNotified = true;
+}
+
+/*
+ * app can poll the get buffer after first rendered signal
+ * Otherwise, app can get render signal whenever it rendered
+ */
+void NativeBufferPlugin::OnRender()
+{
+ // dirty set while adaptor is running
+ if( Running == mState )
+ {
+ mRenderSignalV2.Emit( mNativeBufferPlugin );
+ }
+}
+
+// TODO: need it?
+void NativeBufferPlugin::RenderSync()
+{
+ if( NULL != mAdaptor )
+ {
+ Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).RenderSync();
+ }
+}
+
+native_buffer* NativeBufferPlugin::GetNativeBufferFromOutput()
+{
+ return native_buffer_pool_get_buffer(mPool);
+}
+
+bool NativeBufferPlugin::AddNativeBufferToInput(native_buffer* nativeBuffer)
+{
+ status_t result = native_buffer_pool_add_buffer(mPool, nativeBuffer);
+
+ if(result != STATUS_SUCCESS)
+ {
+ DALI_LOG_WARNING("native_buffer_pool_add_buffer returns %d\n", result);
+ return false;
+ }
+
+ return true;
+}
+
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_NATIVE_BUFFER_PLUGIN_IMPL_H__
+#define __DALI_INTERNAL_NATIVE_BUFFER_PLUGIN_IMPL_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <native-buffer-pool.h>
+#include <boost/bind.hpp>
+
+#include <dali/public-api/math/rect.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+
+// INTERNAL INCLUDES
+
+#include <native-buffer-plugin.h>
+
+namespace Dali
+{
+
+class Adaptor;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class TriggerEvent;
+
+typedef Dali::Rect<int> PositionSize;
+
+namespace ECore
+{
+
+class RenderSurface;
+
+}
+
+/**
+ * Implementation of the NativeBufferPlugin class.
+ */
+class NativeBufferPlugin
+{
+public:
+
+ typedef Dali::NativeBufferPlugin::NativeBufferPluginSignalV2 NativeBufferPluginSignalV2;
+
+ /**
+ * Constructor
+ * @param[in] nbPlugin The public instance of the NativeBufferPlugin
+ * @param[in] nbPool A pointer to a native_buffer_pool object
+ * @param[in] initialWidth The initial width of the plugin and DALis stage
+ * @param[in] initialWidth The initial height of the plugin and DALis stage
+ * @param[in] mode The rendering mode to decide frame rate
+ */
+ NativeBufferPlugin( Dali::NativeBufferPlugin& nbPlugin,
+ unsigned int initialWidth,
+ unsigned int initialHeight,
+ bool isTransparent,
+ unsigned int maxBufferCount,
+ RenderSurface::RenderMode mode,
+ const DeviceLayout& baseLayout);
+
+ /**
+ * Destructor
+ */
+ virtual ~NativeBufferPlugin();
+
+public:
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::Run()
+ */
+ virtual void Run();
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::Pause()
+ */
+ virtual void Pause();
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::Resume()
+ */
+ virtual void Resume();
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::Stop()
+ */
+ virtual void Stop();
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::GetNativeBufferFromOutput()
+ */
+ native_buffer* GetNativeBufferFromOutput();
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::AddNativeBufferToInput()
+ */
+ bool AddNativeBufferToInput(native_buffer* nativeBuffer);
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::ChangeSurfaceSize()
+ */
+ void ChangeSurfaceSize(unsigned int width, unsigned int height);
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::GetBufferCount()
+ */
+ Vector2 GetBufferCount();
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::GetAdaptor()
+ */
+ Dali::Adaptor* GetAdaptor()
+ {
+ return mAdaptor;
+ }
+
+public:
+
+ /**
+ * Called when the adaptor is initialised.
+ */
+ void OnInit();
+
+ /**
+ * Called when the result of rendering was posted to on-screen.
+ * Adaptor (i.e. render thread) can be waiting this sync to render next frame.
+ */
+ void RenderSync();
+
+ /**
+ * Called to notify that Dali has started rendering and atleast one frame has been rendered
+ */
+ void OnFirstRenderCompleted();
+
+ /**
+ * Called to notify that Dali has rendered one frame
+ */
+ void OnRender();
+
+public: // Signals
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::InitSignal()
+ */
+ NativeBufferPluginSignalV2& InitSignal()
+ {
+ return mInitSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::TerminateSignal()
+ */
+ NativeBufferPluginSignalV2& TerminateSignal()
+ {
+ return mTerminateSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::PauseSignal()
+ */
+ NativeBufferPluginSignalV2& PauseSignal()
+ {
+ return mPauseSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::ResumeSignal()
+ */
+ NativeBufferPluginSignalV2& ResumeSignal()
+ {
+ return mResumeSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::FirstRenderCompletedSignal()
+ */
+ NativeBufferPluginSignalV2& FirstRenderCompletedSignal()
+ {
+ return mFirstRenderCompletedSignalV2;
+ }
+
+ /**
+ * @copydoc Dali::NativeBufferPlugin::RenderSignal()
+ */
+ NativeBufferPluginSignalV2& RenderSignal()
+ {
+ return mRenderSignalV2;
+ }
+
+private:
+
+ // Undefined copy constructor
+ NativeBufferPlugin(const NativeBufferPlugin&);
+
+ // Undefined assignment operator
+ NativeBufferPlugin& operator=(NativeBufferPlugin&);
+
+private:
+
+ /**
+ * Create the adaptor
+ */
+ void CreateAdaptor( ECore::RenderSurface &surface, const DeviceLayout& baseLayout );
+
+ /**
+ * Creates a render surface
+ * @param[in] width Width of the surface
+ * @param[in] height Height of the surface
+ * @param[in] isTransparent Whether the surface is transparent
+ * @return A pointer to the new surface
+ */
+ ECore::RenderSurface* CreateSurface( int width, int height, bool isTransparent, unsigned int maxBufferCount );
+
+public:
+
+ enum State
+ {
+ Ready,
+ Running,
+ Suspended,
+ Stopped,
+ };
+
+
+private:
+
+ // Signals
+ NativeBufferPluginSignalV2 mInitSignalV2;
+ NativeBufferPluginSignalV2 mTerminateSignalV2;
+ NativeBufferPluginSignalV2 mPauseSignalV2;
+ NativeBufferPluginSignalV2 mResumeSignalV2;
+ NativeBufferPluginSignalV2 mResetSignalV2;
+ NativeBufferPluginSignalV2 mFirstRenderCompletedSignalV2;
+ NativeBufferPluginSignalV2 mRenderSignalV2;
+
+ Dali::NativeBufferPlugin& mNativeBufferPlugin;
+ native_buffer_provider* mProvider;
+ native_buffer_pool* mPool;
+ Dali::Adaptor* mAdaptor;
+ ECore::RenderSurface* mSurface;
+ TriggerEvent* mRenderNotification; ///< Render Notification trigger
+ State mState;
+ bool mInitialized;
+ bool mFirstRenderCompleteNotified;
+
+public:
+
+ inline static NativeBufferPlugin& GetImplementation(Dali::NativeBufferPlugin& nbPlugin)
+ {
+ return *nbPlugin.mImpl;
+ }
+
+}; // class NativeBufferPlugin
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_NATIVE_BUFFER_PLUGIN_IMPL_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <public-api/native-buffer-plugin.h>
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+#include <mobile/native-buffer-plugin-impl.h>
+
+namespace Dali
+{
+
+NativeBufferPlugin::NativeBufferPlugin( unsigned int initialWidth, unsigned int initialHeight, bool isTransparent, unsigned int maxBufferCount, RenderSurface::RenderMode mode, const DeviceLayout& baseLayout )
+{
+ mImpl = new Internal::Adaptor::NativeBufferPlugin( *this, initialWidth, initialHeight, isTransparent, maxBufferCount, mode, baseLayout );
+}
+
+NativeBufferPlugin::~NativeBufferPlugin()
+{
+ delete mImpl;
+}
+
+void NativeBufferPlugin::Run()
+{
+ mImpl->Run();
+}
+
+void NativeBufferPlugin::Pause()
+{
+ mImpl->Pause();
+}
+
+void NativeBufferPlugin::Resume()
+{
+ mImpl->Resume();
+}
+
+void NativeBufferPlugin::Stop()
+{
+ mImpl->Stop();
+}
+
+Dali::Adaptor* NativeBufferPlugin::GetAdaptor()
+{
+ return mImpl->GetAdaptor();
+}
+
+native_buffer* NativeBufferPlugin::GetNativeBufferFromOutput()
+{
+ return mImpl->GetNativeBufferFromOutput();
+}
+
+bool NativeBufferPlugin::AddNativeBufferToInput(native_buffer* nativeBuffer)
+{
+ return mImpl->AddNativeBufferToInput(nativeBuffer);
+}
+
+void NativeBufferPlugin::ChangeSurfaceSize(unsigned int width, unsigned int height)
+{
+ mImpl->ChangeSurfaceSize(width, height);
+}
+
+Vector2 NativeBufferPlugin::GetBufferCount()
+{
+ return mImpl->GetBufferCount();
+}
+
+NativeBufferPlugin::NativeBufferPluginSignalV2& NativeBufferPlugin::InitSignal()
+{
+ return mImpl->InitSignal();
+}
+
+NativeBufferPlugin::NativeBufferPluginSignalV2& NativeBufferPlugin::TerminateSignal()
+{
+ return mImpl->TerminateSignal();
+}
+
+NativeBufferPlugin::NativeBufferPluginSignalV2& NativeBufferPlugin::PauseSignal()
+{
+ return mImpl->PauseSignal();
+}
+
+NativeBufferPlugin::NativeBufferPluginSignalV2& NativeBufferPlugin::ResumeSignal()
+{
+ return mImpl->ResumeSignal();
+}
+
+NativeBufferPlugin::NativeBufferPluginSignalV2& NativeBufferPlugin::FirstRenderCompletedSignal()
+{
+ return mImpl->FirstRenderCompletedSignal();
+}
+
+NativeBufferPlugin::NativeBufferPluginSignalV2& NativeBufferPlugin::RenderSignal()
+{
+ return mImpl->RenderSignal();
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_ACCESSIBILITY_ACTION_HANDLER_H__
+#define __DALI_ACCESSIBILITY_ACTION_HANDLER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+
+namespace Dali DALI_IMPORT_API
+{
+
+/**
+ * AccessibilityActionHandler is an abstract interface, used by Dali to handle accessibility actions
+ * passed by the accessibility manager.
+ */
+class AccessibilityActionHandler
+{
+public:
+
+ /**
+ * Change the accessibility status when Accessibility feature(screen-reader) turned on or off.
+ * @return whether the status is changed or not.
+ */
+ virtual bool ChangeAccessibilityStatus() = 0;
+
+ /**
+ * Clear the accessibility focus from the current focused actor.
+ * @return whether the focus is cleared or not.
+ */
+ virtual bool ClearAccessibilityFocus() = 0;
+
+ /**
+ * Perform the accessibility action to move focus to the previous focusable actor (by one finger flick up).
+ * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionPrevious(bool allowEndFeedback) = 0;
+
+ /**
+ * Perform the accessibility action to move focus to the next focusable actor (by one finger flick down).
+ * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionNext(bool allowEndFeedback) = 0;
+
+ /**
+ * Perform the accessibility action to move focus to the previous focusable actor (by one finger flick left).
+ * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionReadPrevious(bool allowEndFeedback) = 0;
+
+ /**
+ * Perform the accessibility action to move focus to the next focusable actor (by one finger flick right).
+ * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionReadNext(bool allowEndFeedback) = 0;
+
+ /**
+ * Perform the accessibility action to focus and read the actor (by one finger tap or move).
+ * @param allowReadAgain true if the action read again the same object (i.e. read action)
+ * false if the action just read when the focus object is changed (i.e. over action)
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionRead(bool allowReadAgain) = 0;
+
+ /**
+ * Perform the accessibility action to activate the current focused actor (by one finger double tap).
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionActivate() = 0;
+
+ /**
+ * Perform the accessibility action to change the value when the current focused actor is a slider
+ * (by double finger down and move up and right).
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionUp() = 0;
+
+ /**
+ * Perform the accessibility action to change the value when the current focused actor is a slider
+ * (by double finger down and move down and left).
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionDown() = 0;
+
+ /**
+ * Perform the accessibility action to navigate back (by two fingers circle draw).
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionBack() = 0;
+
+ /**
+ * Perform the accessibility action to mouse move (by one finger tap & hold and move).
+ * @param touchEvent touch event structure
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionTouch(const Dali::TouchEvent& touchEvent) = 0;
+
+}; // class AccessibilityActionHandler
+
+} // namespace Dali
+
+#endif // __DALI_ACCESSIBILITY_ACTION_HANDLER_H__
--- /dev/null
+#ifndef __DALI_ACCESSIBILITY_GESTURE_HANDLER_H__
+#define __DALI_ACCESSIBILITY_GESTURE_HANDLER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/events/pan-gesture-event.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+/**
+ * AccessibilityGestureHandler is an interface used by Dali to handle accessibility gestures
+ * passed by the accessibility manager.
+ */
+class AccessibilityGestureHandler
+{
+public:
+
+ /**
+ * Handle the accessibility pan gesture.
+ * @param[in] panEvent The pan event to be handled.
+ * @return whether the gesture is handled successfully or not.
+ */
+ virtual bool HandlePanGesture( const Integration::PanGestureEvent& panEvent ) = 0;
+
+}; // class AccessibilityGestureHandler
+
+} // namespace Dali
+
+#endif // __DALI_ACCESSIBILITY_GESTURE_HANDLER_H__
--- /dev/null
+#ifndef __DALI_ACCESSIBILITY_MANAGER_H__
+#define __DALI_ACCESSIBILITY_MANAGER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/events/touch-event.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class AccessibilityManager;
+}
+}
+
+class AccessibilityActionHandler;
+class AccessibilityGestureHandler;
+class TouchPoint;
+
+/**
+ * @brief The AccessibilityManager provides signals when accessibility & screen reader feature turned on in device.
+ */
+class AccessibilityManager : public BaseHandle
+{
+public:
+
+ // Typedefs
+
+ /**
+ * @brief Accessibility Action Signal.
+ *
+ * Signal connected callback should return the result
+ */
+ typedef SignalV2< bool ( AccessibilityManager& ) > AccessibilityActionSignalV2; ///< Generic signal type
+ typedef SignalV2< bool (AccessibilityManager&, const Dali::TouchEvent&)> AccessibilityActionScrollSignalV2; ///< Scroll signal type
+
+ // Signal Names
+ static const char* const SIGNAL_STATUS_CHANGED; ///< name "accessibility-status-changed"
+ static const char* const SIGNAL_ACTION_NEXT; ///< name "accessibility-action-next"
+ static const char* const SIGNAL_ACTION_PREVIOUS; ///< name "accessibility-action-previous"
+ static const char* const SIGNAL_ACTION_ACTIVATE; ///< name "accessibility-action-activatae"
+ static const char* const SIGNAL_ACTION_OVER; ///< name "accessibility-action-over"
+ static const char* const SIGNAL_ACTION_READ; ///< name "accessibility-action-read"
+ static const char* const SIGNAL_ACTION_READ_NEXT; ///< name "accessibility-action-read-next"
+ static const char* const SIGNAL_ACTION_READ_PREVIOUS; ///< name "accessibility-action-read-prev"
+ static const char* const SIGNAL_ACTION_UP; ///< name "accessibility-action-up"
+ static const char* const SIGNAL_ACTION_DOWN; ///< name "accessibility-action-down"
+ static const char* const SIGNAL_ACTION_CLEAR_FOCUS; ///< name "accessibility-action-clear-focus"
+ static const char* const SIGNAL_ACTION_BACK; ///< name "accessibility-action-back"
+ static const char* const SIGNAL_ACTION_SCROLL; ///< name "accessibility-action-scroll"
+
+ /**
+ * @brief Create an uninitialized handle.
+ *
+ * This can be initialized by calling getting the manager from Dali::Adaptor.
+ */
+ AccessibilityManager();
+
+ /**
+ * @brief Retrieve a handle to the AccessibilityManager.
+ *
+ * @return A handle to the AccessibilityManager.
+ */
+ static AccessibilityManager Get();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~AccessibilityManager();
+
+ /**
+ * @brief Returns the current position of the read action.
+ * @return The current event position.
+ */
+ Vector2 GetReadPosition() const;
+
+ /**
+ * @brief Query whether the accessibility(screen-reader) is enabled.
+ *
+ * The accessibility will be enabled by system setting.
+ * @return True if the accessibility(screen-reader) is enabled.
+ */
+ bool IsEnabled() const;
+
+ /**
+ * @brief Set the handler to handle accessibility actions.
+ *
+ * @param[in] handler The Accessibility action handler.
+ * @note Handlers should remove themselves when they are destroyed.
+ */
+ void SetActionHandler(AccessibilityActionHandler& handler);
+
+ /**
+ * @brief Set the handler to handle accessibility gestures.
+ *
+ * @param[in] handler The Accessibility gesture handler.
+ * @note Handlers should remove themselves when they are destroyed.
+ */
+ void SetGestureHandler(AccessibilityGestureHandler& handler);
+
+ /**
+ * @brief Handle the accessibility action to move focus to the next focusable actor
+ * (by one finger flick down).
+ *
+ * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
+ * @return Whether the action is performed successfully or not.
+ */
+ bool HandleActionNextEvent(bool allowEndFeedback = true);
+
+ /**
+ * @brief Handle the accessibility action to move focus to the previous focusable actor
+ * (by one finger flick up).
+ *
+ * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
+ * @return Whether the action is performed successfully or not.
+ */
+ bool HandleActionPreviousEvent(bool allowEndFeedback = true);
+
+ /**
+ * @brief Handle the accessibility action to activate the current focused actor (by one
+ * finger double tap)
+ *
+ * @return Whether the action is performed successfully or not.
+ */
+ bool HandleActionActivateEvent();
+
+ /**
+ * @brief Handle the accessibility action to focus and read the actor (by one finger tap or move).
+ *
+ * @param x x position of event
+ * @param y y position of event
+ * @param allowReadAgain true if the action read again the same object (i.e. read action)
+ * false if the action just read when the focus object is changed (i.e. over action)
+ * @return Whether the action is performed successfully or not.
+ */
+ bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
+
+ /**
+ * @brief Handle the accessibility action to move focus to the next focusable actor
+ * (by one finger flick right).
+ *
+ * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
+ * @return Whether the action is performed successfully or not.
+ */
+ bool HandleActionReadNextEvent(bool allowEndFeedback = true);
+
+ /**
+ * @brief Handle the accessibility action to move focus to the previous focusable actor
+ * (by one finger flick up).
+ *
+ * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the front
+ * @return Whether the action is performed successfully or not.
+ */
+ bool HandleActionReadPreviousEvent(bool allowEndFeedback = true);
+
+ /**
+ * @brief Handle the accessibility action to change the value when the current focused
+ * actor is a slider (by double finger down and move up and right).
+ *
+ * @return Whether the action is performed successfully or not.
+ */
+ bool HandleActionUpEvent();
+
+ /**
+ * @brief Handle the accessibility action to change the value when the current focused
+ * actor is a slider (by double finger down and move down and left).
+ *
+ * @return Whether the action is performed successfully or not.
+ */
+ bool HandleActionDownEvent();
+
+ /**
+ * @brief Handle the accessibility action to clear the focus from the current focused
+ * actor if any, so that no actor is focused in the focus chain.
+ *
+ * @return Whether the action is performed successfully or not.
+ */
+ bool HandleActionClearFocusEvent();
+
+ /**
+ * @brief Handle the accessibility action to scroll when there is a scroller on the touched position
+ * (by 2 finger touch & move, 2 finger flick).
+ *
+ * @param[in] point The touch point information.
+ * @param[in] timeStamp The time the touch occurred.
+ * @return Whether the action is performed successfully or not.
+ */
+ bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
+
+ /**
+ * @brief Handle the accessibility action to move for the current focused actor
+ * (by 1 finger tap & hold and move).
+ *
+ * @param[in] point The touch point information.
+ * @param[in] timeStamp The time the touch occurred.
+ * @return Whether the action is performed successfully or not.
+ */
+ bool HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp);
+
+ /**
+ * @brief Handle the accessibility action to navigate back (by two fingers circle draw).
+ * @return Whether the action is performed successfully or not.
+ */
+ bool HandleActionBackEvent();
+
+ /**
+ * @brief Handle the accessibility action to enable the feature.
+ */
+ void HandleActionEnableEvent();
+
+ /**
+ * @brief Handle the accessibility action to disable the feature.
+ */
+ void HandleActionDisableEvent();
+
+public: // Signals
+
+ /**
+ * @brief This is emitted when accessibility(screen-reader) feature turned on or off.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionSignalV2& StatusChangedSignal();
+
+ /**
+ * @brief This is emitted when accessibility action is received to move focus to the next
+ * focusable actor (by one finger flick down).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionSignalV2& ActionNextSignal();
+
+ /**
+ * @brief This is emitted when accessibility action is received to move focus to the previous
+ * focusable actor (by one finger flick up).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionSignalV2& ActionPreviousSignal();
+
+ /**
+ * @brief This is emitted when accessibility action is received to activate the current focused
+ * actor (by one finger double tap).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionSignalV2& ActionActivateSignal();
+
+ /**
+ * @brief This is emitted when accessibility action is received to focus and read the actor
+ * (by one finger tap).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionSignalV2& ActionReadSignal();
+
+ /**
+ * @brief This is emitted when accessibility action is received to focus and read the actor
+ * (by one finger move).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionSignalV2& ActionOverSignal();
+
+ /**
+ * @brief This is emitted when accessibility action is received to move focus to the next
+ * focusable actor (by one finger flick right).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionSignalV2& ActionReadNextSignal();
+
+ /**
+ * @brief This is emitted when accessibility action is received to move focus to the previous
+ * focusable actor (by one finger flick left).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionSignalV2& ActionReadPreviousSignal();
+
+ /**
+ * @brief This is emitted when accessibility action is received to change the value when the
+ * current focused actor is a slider (by double finger down and move up and right).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionSignalV2& ActionUpSignal();
+
+ /**
+ * @brief This is emitted when accessibility action is received to change the value when the
+ * current focused actor is a slider (by double finger down and move down and left).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionSignalV2& ActionDownSignal();
+
+ /**
+ * @brief This is emitted when accessibility action is received to clear the focus from the
+ * current focused actor if any, so that no actor is focused in the focus chain.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionSignalV2& ActionClearFocusSignal();
+
+ /**
+ * @brief This is emitted when accessibility action is received to navigate back (by two
+ * fingers circle draw).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionSignalV2& ActionBackSignal();
+
+ /**
+ * @brief This is emitted when accessibility action is received to handle scroll event (by two
+ * fingers drag).
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * bool YourCallback( AccessibilityManager& manager, const TouchEvent& event );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ AccessibilityActionScrollSignalV2& ActionScrollSignal();
+
+public: // Not intended for application developers
+
+ /**
+ * @brief Creates a handle using the Adaptor::Internal implementation.
+ *
+ * @param[in] manager The AccessibilityManager implementation.
+ */
+ AccessibilityManager( Internal::Adaptor::AccessibilityManager& manager );
+
+ /**
+ * @brief This constructor is used by AccessibilityManager::Get().
+ *
+ * @param[in] manager A pointer to the accessibility manager.
+ */
+ AccessibilityManager( Internal::Adaptor::AccessibilityManager* manager );
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_ACCESSIBILITY_MANAGER_H__
--- /dev/null
+#ifndef __DALI_ADAPTOR_H__
+#define __DALI_ADAPTOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+#include "window.h"
+#include "tts-player.h"
+#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/math/rect.h>
+#include <dali/public-api/events/touch-event.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+struct DeviceLayout;
+class RenderSurface;
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class Adaptor;
+}
+}
+
+/**
+ * @brief An Adaptor object is used to initialize and control how Dali runs.
+ *
+ * It provides a lifecycle interface that allows the application
+ * writer to provide their own main loop and other platform related
+ * features.
+ *
+ * The Adaptor class provides a means for initialising the resources required by the Dali::Core.
+ *
+ * When dealing with platform events, the application writer MUST ensure that Dali is called in a
+ * thread-safe manner.
+ *
+ * As soon as the Adaptor class is created and started, the application writer can initialise their
+ * Dali::Actor objects straight away or as required by the main loop they intend to use (there is no
+ * need to wait for an initialise signal as per the Dali::Application class).
+ *
+ * The Adaptor does emit a Resize signal which informs the user when the surface is resized.
+ * Tizen and Linux Adaptors should follow the example below:
+ *
+ * @code
+ * void CreateProgram(DaliAdaptor& adaptor)
+ * {
+ * // Create Dali components...
+ * // Can instantiate adaptor here instead, if required
+ * }
+ *
+ * int main ()
+ * {
+ * // Initialise platform
+ * MyPlatform.Init();
+ *
+ * // Create an 800 by 1280 window positioned at (0,0).
+ * Dali::PositionSize positionSize(0, 0, 800, 1280);
+ * Dali::Window window = Dali::Window::New( positionSize, "My Application" );
+ *
+ * // Create an adaptor which uses that window for rendering
+ * Dali::Adaptor adaptor = Dali::Adaptor::New( window );
+ * adaptor.Start();
+ *
+ * CreateProgram(adaptor);
+ * // Or use this as a callback function depending on the platform initialisation sequence.
+ *
+ * // Start Main Loop of your platform
+ * MyPlatform.StartMainLoop();
+ *
+ * return 0;
+ * }
+ * @endcode
+ *
+ * If required, you can also connect class member functions to a signal:
+ *
+ * @code
+ * MyApplication application;
+ * adaptor.ResizedSignal().Connect(&application, &MyApplication::Resize);
+ * @endcode
+ *
+ * @see RenderSurface
+ */
+class Adaptor
+{
+public:
+
+ typedef SignalV2< void (Adaptor&) > AdaptorSignalV2; ///< Generic Type for adaptor signals
+
+public:
+ /**
+ * @brief Create a new adaptor using the window.
+ *
+ * @param[in] window The window to draw onto
+ * @note The default base layout DeviceLayout::DEFAULT_BASE_LAYOUT will be used.
+ * @return a reference to the adaptor handle
+ */
+ static Adaptor& New( Window window );
+
+ /**
+ * @brief Create a new adaptor using the window.
+ *
+ * @param[in] window The window to draw onto
+ * @param[in] baseLayout The base layout that the application has been written for
+ * @return a reference to the adaptor handle
+ */
+ static Adaptor& New( Window window, const DeviceLayout& baseLayout );
+
+ /**
+ * @brief Virtual Destructor.
+ */
+ virtual ~Adaptor();
+
+public:
+
+ /**
+ * @brief Starts the Adaptor.
+ */
+ void Start();
+
+ /**
+ * @brief Pauses the Adaptor.
+ */
+ void Pause();
+
+ /**
+ * @brief Resumes the Adaptor, if previously paused.
+ *
+ * @note If the adaptor is not paused, this does not do anything.
+ */
+ void Resume();
+
+ /**
+ * @brief Stops the Adaptor.
+ */
+ void Stop();
+
+ /**
+ * @brief Ensures that the function passed in is called from the main loop when it is idle.
+ *
+ * A callback of the following type may be used:
+ * @code
+ * void MyFunction();
+ * @endcode
+ *
+ * @param[in] callBack The function to call.
+ * @return true if added successfully, false otherwise
+ */
+ bool AddIdle( boost::function<void(void)> callBack );
+
+ /**
+ * @brief Get the render surface the adaptor is using to render to.
+ *
+ * @return reference to current render surface
+ */
+ RenderSurface& GetSurface();
+
+ /**
+ * @brief Returns a reference to the instance of the adaptor used by the current thread.
+ *
+ * @return A reference to the adaptor.
+ * @pre The adaptor has been initialised.
+ * @note This is only valid in the main thread.
+ */
+ static Adaptor& Get();
+
+ /**
+ * @brief Checks whether the adaptor is available.
+ *
+ * @return true, if it is available, false otherwise.
+ */
+ static bool IsAvailable();
+
+ /**
+ * @brief Registers the singleton of Dali handle with its type info.
+ *
+ * The singleton will be kept alive for the life time of the
+ * adaptor.
+ * @note This is not intended for application developers.
+ * @param[in] info The type info of the Dali handle generated by the compiler.
+ * @param[in] singleton The Dali handle to be registered
+ */
+ void RegisterSingleton(const std::type_info& info, BaseHandle singleton);
+
+ /**
+ * @brief Gets the singleton for the given type.
+ *
+ * @note This is not intended for application developers.
+ * @param[in] info The type info of the given type.
+ * @return the Dali handle if it is registered as a singleton or an uninitialized handle.
+ */
+ BaseHandle GetSingleton(const std::type_info& info) const;
+
+ /**
+ * @brief Call this method to notify Dali when the system language changes.
+ *
+ * Use this only when NOT using Dali::Application, As Application created using
+ * Dali::Application will automatically receive notification of language change.
+ * When Dali::Application is not used, the application developer should
+ * use app-core to receive language change notifications and should update Dali
+ * by calling this method.
+ */
+ void NotifyLanguageChanged();
+
+ /**
+ * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to
+ * trigger a pinch gesture
+ *
+ * @param[in] distance The minimum pinch distance in pixels
+ */
+ void SetMinimumPinchDistance(float distance);
+
+public: // Signals
+
+ /**
+ * @brief The user should connect to this signal if they need to perform any
+ * special activities when the surface Dali is being rendered on is resized.
+ *
+ * @return The signal to connect to
+ */
+ AdaptorSignalV2& ResizedSignal();
+
+ /**
+ * @brief This signal is emitted when the language is changed on the device.
+ *
+ * @return The signal to connect to
+ */
+ AdaptorSignalV2& LanguageChangedSignal();
+
+private:
+
+ // Undefined
+ Adaptor(const Adaptor&);
+ Adaptor& operator=(Adaptor&);
+
+private:
+
+ /**
+ * @brief Create an uninitialized Adaptor.
+ */
+ DALI_INTERNAL Adaptor();
+
+ Internal::Adaptor::Adaptor* mImpl; ///< Implementation object
+ friend class Internal::Adaptor::Adaptor;
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_ADAPTOR_H__
--- /dev/null
+#ifndef __DALI_APPLICATION_H__
+#define __DALI_APPLICATION_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+#include <string>
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/common/view-mode.h>
+
+#include "style-monitor.h"
+#include "device-layout.h"
+#include "window.h"
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class Application;
+}
+}
+
+/**
+ * An Application class object should be created by every application
+ * that wishes to use Dali. It provides a means for initialising the
+ * resources required by the Dali::Core.
+ *
+ * The Application class emits several signals which the user can
+ * connect to. The user should not create any Dali objects in the main
+ * function and instead should connect to the Init signal of the
+ * Application and create the Dali objects in the connected callback.
+ *
+ * Applications should follow the example below:
+ *
+ * @code
+ * void CreateProgram(Application app)
+ * {
+ * // Create Dali components...
+ * // Can instantiate here, if required
+ * }
+ *
+ * int main (int argc, char **argv)
+ * {
+ * Application app = Application::New(&argc, &argv);
+ * app.InitSignal().Connect(&CreateProgram);
+ * app.MainLoop();
+ * }
+ * @endcode
+ *
+ * If required, you can also connect class member functions to a signal:
+ *
+ * @code
+ * MyApplication app;
+ * app.ResumeSignal().Connect(&app, &MyApplication::Resume);
+ * @endcode
+ *
+ * This class accepts command line arguments as well. The following options are supported:
+ *
+ * @code
+ * --no-vsync Disable VSync on Render
+ * -w|--width Stage Width
+ * -h|--height Stage Height
+ * -d|--dpi Emulated DPI
+ * --help Help
+ * @endcode
+ *
+ * When the above options are found, they are stripped from argv, and argc is updated appropriately.
+ */
+class Application : public BaseHandle
+{
+public:
+
+ typedef SignalV2< void (Application&) > AppSignalV2;
+
+ /**
+ * Decides whether a Dali application window is opaque or transparent.
+ */
+ enum WINDOW_MODE
+ {
+ OPAQUE = 0, ///< The window will be opaque
+ TRANSPARENT = 1 ///< The window transparency will match the alpha value set in Dali::Stage::SetBackgroundcolor()
+ };
+
+public:
+
+ /**
+ * This is the constructor for applications.
+ *
+ * @param[in,out] argc A pointer to the number of arguments
+ * @param[in,out] argv A pointer the the argument list
+ *
+ * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
+ * @note Supported options are stripped from argv, and argc is updated appropriately.
+ */
+ static Application New( int* argc, char **argv[] );
+
+ /**
+ * This is the constructor for applications with a name
+ *
+ * @param[in,out] argc A pointer to the number of arguments
+ * @param[in,out] argv A pointer the the argument list
+ * @param[in] name A name of application
+ *
+ * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
+ * @note Supported options are stripped from argv, and argc is updated appropriately.
+ */
+ static Application New( int* argc, char **argv[], const std::string& name );
+
+ /**
+ * This is the constructor for applications with a name, and also require a
+ * transparent top-level window
+ *
+ * @param[in,out] argc A pointer to the number of arguments
+ * @param[in,out] argv A pointer the the argument list
+ * @param[in] name A name of application
+ * @param[in] windowMode A member of WINDOW_MODE
+ *
+ * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
+ * @note Supported options are stripped from argv, and argc is updated appropriately.
+ */
+ static Application New( int* argc, char **argv[], const std::string& name, WINDOW_MODE windowMode );
+
+ /**
+ * This is the constructor for applications when a layout for the application is specified.
+ *
+ * @param[in,out] argc A pointer to the number of arguments
+ * @param[in,out] argv A pointer the the argument list
+ * @param[in] baseLayout The base layout that the application has been written for
+ *
+ * @note Supported options are stripped from argv, and argc is updated appropriately.
+ */
+ static Application New( int* argc, char **argv[], const DeviceLayout& baseLayout );
+
+ /**
+ * This is the constructor for applications with a name and when a layout for the application is specified.
+ *
+ * @param[in,out] argc A pointer to the number of arguments
+ * @param[in,out] argv A pointer the the argument list
+ * @param[in] name A name of application
+ * @param[in] baseLayout The base layout that the application has been written for
+ *
+ * @note Supported options are stripped from argv, and argc is updated appropriately.
+ */
+ static Application New( int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout );
+
+ /**
+ * Construct an empty handle
+ */
+ Application();
+
+ /**
+ * Copy Constructor
+ */
+ Application( const Application& application );
+
+ /**
+ * Assignment operator
+ */
+ Application& operator=( const Application& applicaton );
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~Application();
+
+public:
+ /**
+ * This starts the application.
+ */
+ void MainLoop();
+
+ /**
+ * This lowers the application to bottom without actually quitting it
+ */
+ void Lower();
+
+ /**
+ * This quits the application. Tizen applications should use Lower to improve re-start performance unless they need to Quit completely.
+ */
+ void Quit();
+
+ /**
+ * This returns a handle to the Orientation object used by Application which allows
+ * the user to determine the orientation of the device and connect to a
+ * signal emitted whenever the orientation changes.
+ * @return A handle to the Orientation object used by the Application
+ */
+ Orientation GetOrientation();
+
+ /**
+ * Ensures that the function passed in is called from the main loop when it is idle.
+ *
+ * A callback of the following type may be used:
+ * @code
+ * void MyFunction();
+ * @endcode
+ *
+ * @param[in] callBack The function to call.
+ * @return true if added successfully, false otherwise
+ */
+ bool AddIdle(boost::function<void(void)> callBack);
+
+ /**
+ * Retrieves the window used by the Application class.
+ * The application writer can use the window to change indicator and orientation
+ * properties.
+ * @return A handle to the window
+ */
+ Window GetWindow();
+
+ /**
+ * Returns the local thread's instance of the Application class.
+ * @return A reference to the local thread's Application class instance.
+ * @pre The Application class has been initialised.
+ * @note This is only valid in the main thread.
+ */
+ static Application Get();
+
+public: // Stereoscopy
+
+ /**
+ * Set the stereoscopic 3D viewing mode for the application
+ * @param[in] viewMode The new viewing mode
+ */
+ void SetViewMode( ViewMode viewMode );
+
+ /**
+ * Get the current stereoscopic 3D viewing mode.
+ * @return The current stereoscopic 3D viewing mode.
+ */
+ ViewMode GetViewMode() const;
+
+ /**
+ * Set the stereo base (eye seperation) for stereoscopic 3D
+ * @param[in] stereoBase The stereo base (eye seperation) for stereoscopic 3D
+ */
+ void SetStereoBase( float stereoBase );
+
+ /**
+ * Get the stereo base (eye seperation) for stereoscopic 3D
+ * @return The stereo base (eye seperation) for stereoscopic 3D
+ */
+ float GetStereoBase() const;
+
+public: // Signals
+
+ /**
+ * The user should connect to this signal to determine when they should initialise
+ * their application
+ */
+ AppSignalV2& InitSignal();
+
+ /**
+ * The user should connect to this signal to determine when they should terminate
+ * their application
+ */
+ AppSignalV2& TerminateSignal();
+
+ /**
+ * The user should connect to this signal if they need to perform any special
+ * activities when the application is about to be paused.
+ */
+ AppSignalV2& PauseSignal();
+
+ /**
+ * The user should connect to this signal if they need to perform any special
+ * activities when the application has resumed.
+ */
+ AppSignalV2& ResumeSignal();
+
+ /**
+ * This signal is sent when the system requires the user to reinitialise itself.
+ */
+ AppSignalV2& ResetSignal();
+
+ /**
+ * This signal is emitted when the window the application is rendering on is resized.
+ */
+ AppSignalV2& ResizeSignal();
+
+ /**
+ * This signal is emitted when the language is changed on the device.
+ */
+ AppSignalV2& LanguageChangedSignal();
+
+public: // Not intended for application developers
+ /**
+ * Internal constructor
+ */
+ explicit DALI_INTERNAL Application(Internal::Adaptor::Application* application);
+};
+
+} // namespace Dali
+
+#endif // __DALI_APPLICATION_H__
--- /dev/null
+#ifndef __DALI_CLIPBOARD_EVENT_NOTIFIER_H__
+#define __DALI_CLIPBOARD_EVENT_NOTIFIER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal-v2.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class ClipboardEventNotifier;
+}
+}
+
+/**
+ * @brief The ClipboardEventNotifier provides signals when clipboard events are received from the device.
+ */
+class ClipboardEventNotifier : public BaseHandle
+{
+public:
+
+ // Typedefs
+
+ /**
+ * @brief Clipboard event
+ */
+ typedef SignalV2< void ( ClipboardEventNotifier& ) > ClipboardEventSignalV2;
+
+ // Signal Names
+ static const char* const SIGNAL_CONTENT_SELECTED; ///< name "content-selected"
+
+ /**
+ * @brief Create an uninitialized handle.
+ *
+ * This can be initialized by getting the notifier from Dali::Adaptor.
+ */
+ ClipboardEventNotifier();
+
+ /**
+ * @brief Retrieve a handle to the ClipboardEventNotifier instance.
+ *
+ * @return A handle to the ClipboardEventNotifier
+ */
+ static ClipboardEventNotifier Get();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~ClipboardEventNotifier();
+
+ /**
+ * @brief Returns the selected content.
+ * @return A reference to the string representing the selected content.
+ */
+ const std::string& GetContent() const;
+
+ /**
+ * @brief Sets the selected content.
+ * @param[in] content A string that represents the content that has been selected.
+ */
+ void SetContent( const std::string& content );
+
+ /**
+ * @brief Clears the stored content.
+ */
+ void ClearContent();
+
+ /**
+ * @brief Called when content is selected in the clipboard.
+ */
+ void EmitContentSelectedSignal();
+
+public: // Signals
+
+ /**
+ * @brief This is emitted when content is selected from the clipboard.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallback( ClipboardEventNotifier& notifier );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ ClipboardEventSignalV2& ContentSelectedSignal();
+
+public: // Not intended for application developers
+
+ /**
+ * @brief This constructor is used by ClipboardEventNotifier::Get().
+ *
+ * @param[in] notifier A pointer to the drag and drop notifier.
+ */
+ ClipboardEventNotifier( Internal::Adaptor::ClipboardEventNotifier* notifier );
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_CLIPBOARD_EVENT_NOTIFIER_H__
--- /dev/null
+#ifndef __DALI_CLIPBOARD_H__
+#define __DALI_CLIPBOARD_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/math/rect.h>
+#include <dali/public-api/object/base-handle.h>
+
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+
+namespace Adaptor
+{
+class Clipboard;
+}
+}
+
+/**
+ * @brief Interface to the device's clipboard.
+ *
+ * Clipboard can manage it's item and set show / hide status.
+ */
+
+class Clipboard : public BaseHandle
+{
+public:
+ /**
+ * @brief Create an uninitialized Clipboard.
+ *
+ * this can be initialized with one of the derived Clipboard' New() methods
+ */
+ Clipboard();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~Clipboard();
+
+ /**
+ * @brief This constructor is used by Adaptor::GetClipboard().
+ *
+ * @param[in] clipboard A pointer to the clipboard.
+ */
+ Clipboard( Internal::Adaptor::Clipboard* clipboard );
+
+ /**
+ * @brief Retrieve a handle to the ClipboardEventNotifier instance.
+ *
+ * @return A handle to the Clipboard
+ */
+ static Clipboard Get();
+
+ /**
+ * @brief Send the given string to the clipboard.
+ *
+ * @param[in] itemData string to send to clip board
+ * @return bool true if the internal clip board sending was successful.
+ */
+ bool SetItem( const std::string& itemData );
+
+ /**
+ * @brief Retreive the string at the given index in the clipboard.
+ *
+ * @param[in] index item in clipboard list to retrieve
+ * @return string the text item at the current index.
+ */
+ std::string GetItem( unsigned int index );
+
+ /**
+ * @brief Returns the number of item currently in the clipboard.
+ *
+ * @return unsigned int number of clipboard items
+ */
+ unsigned int NumberOfItems();
+
+ /**
+ * @brief Show the clipboard window.
+ */
+ void ShowClipboard();
+
+ /**
+ * @brief Hide the clipboard window.
+ */
+ void HideClipboard();
+
+};
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_CLIPBOARD_H__
--- /dev/null
+#ifndef __DALI_COLOR_CONTROLLER_H__
+#define __DALI_COLOR_CONTROLLER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/public-api/object/base-handle.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class ColorController;
+}
+}
+
+/**
+ * Color controller currently caches the changeable color table which updates with the theme change
+ *
+ * It provides the functionality of retrieving a RGBA color by passing in the color code string.
+ */
+class ColorController : public BaseHandle
+{
+public:
+
+ /**
+ * @brief Create an uninitialized ColorController handle.
+ */
+ ColorController();
+
+ /**
+ * @brief Creates a copy of the handle.
+ *
+ * The copy will point to the same implementation as the original.
+ * @param[in] colorController The Color Controller to copy from.
+ */
+ ColorController( const ColorController& colorController);
+
+ /**
+ * @copydoc Dali::BaseHandle::operator=
+ */
+ using BaseHandle::operator=;
+
+ /**
+ * @brief Retrieve the initialized instance of the ColorController.
+ *
+ * @return Handle to ColorController.
+ */
+ static ColorController Get();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~ColorController();
+
+ /**
+ * @brief Retrieve the RGB value by given the color code.
+ *
+ * @param[in] colorCode The color code string.
+ * @param[out] colorValue The RGBA color
+ * @return true if the color code exists, otherwise false
+ */
+ bool RetrieveColor( const std::string& colorCode, Vector4& colorValue );
+
+ /**
+ * @brief Retrieve the RGB values by given the color code.
+ *
+ * @param[in] colorCode The color code string.
+ * @param[out] textColor The text color.
+ * @param[out] textOutlineColor The text outline color.
+ * @param[out] textShadowColor The text shadow color.
+ * @return true if the color code exists, otherwise false
+ */
+ bool RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor);
+
+
+public: // Not intended for application developers
+ /**
+ * @brief This constructor is used internally to create a handle from an object pointer.
+ * @param [in] colorController A pointer the internal color controller.
+ */
+ explicit DALI_INTERNAL ColorController(Internal::Adaptor::ColorController* colorController);
+};
+
+
+} //namespace Dali
+
+#endif /* __DALI_COLOR_CONTROLLER_H__ */
--- /dev/null
+#ifndef __DALI_DOC_H__
+#define __DALI_DOC_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @ingroup CAPI_DALI_MODULE
+ * @defgroup CAPI_DALI_ADAPTOR_MODULE Adaptor Framework
+ * @section CAPI_DALI_ADAPTOR_MODULE_HEADER Required Header
+ * \#include <dali/dali.h>
+ * @section CAPI_DALI_ADAPTOR_MODULE_OVERVIEW Overview
+ * The adaptor framework provides interfaces onto the platform for Dali.
+ * <table> <tr><th>API</th><th>Description</th></tr>
+ * <tr><td>@ref Dali::EvasPlugin </td><td>Used by EFL applications that wish to use Dali.</td></tr>
+ * <tr><td>@ref Dali::NativeBufferPlugin </td><td>Used by Tizen applications that wish to capture Dali output in a buffer.</td></tr>
+ * <tr><td>@ref Dali::AccessibilityManager </td><td>Provides signals for accessibility and screen reader.</td></tr>
+ * <tr><td>@ref Dali::Adaptor </td><td>An Adaptor object is used to initialize and control how Dali runs.</td></tr>
+ * <tr><td>@ref Dali::ClipboardEventNotifier </td><td>Provides signals when clipboard events are received from the device.</td></tr>
+ * <tr><td>@ref Dali::Clipboard </td><td>Interface to the device's clipboard.</td></tr>
+ * <tr><td>@ref Dali::DeviceLayout </td><td> The attributes of the screen on the device.</td></tr>
+ * <tr><td>@ref Dali::DragAndDropDetector </td><td>The DragAndDropDetector s provides signals when draggable objects are dragged into the Dali window.</td></tr>
+ * <tr><td>@ref Dali::HapticPlayer </td><td></td>Plays haptic effects.</tr>
+ * <tr><td>@ref Dali::ImfManager </td><td>Interface to the device's Input framework.</td></tr>
+ * <tr><td>@ref Dali::Orientation </td><td>Determines the device orientation.</td></tr>
+ * <tr><td>@ref Dali::PixmapImage </td><td>Used for displaying native Pixmap images.</td></tr>
+ * <tr><td>@ref Dali::RenderSurface </td><td>Interface for a render surface onto which Dali draws.</td></tr>
+ * <tr><td>@ref Dali::SoundPlayer </td><td>Class for playing sound effects.</td></tr>
+ * <tr><td>@ref Dali::StyleChange </td><td>Class for describing what style information has changed.</td></tr>
+ * <tr><td>@ref Dali::StyleMonitor </td><td>Monitors the platform for style changes.</td></tr>
+ * <tr><td>@ref Dali::Timer </td><td>Mechanism to issue simple periodic or one-shot events.</td></tr>
+ * <tr><td>@ref Dali::TtsPlayer </td><td>Interface to the Text-to-Speech player.</td></tr>
+ * <tr><td>@ref Dali::VirtualKeyboard </td><td>Interface to the virtual keyboard.</td></tr>
+ * <tr><td>@ref Dali::Window </td><td>The Window class is used for drawing Dali.</td></tr>
+ * </table>
+ */
--- /dev/null
+#ifndef __DALI_H__
+#define __DALI_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/public-api/dali-core.h>
+
+// Application / UI Framework adaption
+
+// These defines come from running pkg-config --cflags with the correct package config file
+
+#if defined(DALI_LIVEBOX_PLUGIN)
+#include <dali/public-api/livebox-plugin.h>
+#endif
+
+#if defined(DALI_EVAS_PLUGIN)
+#include <dali/public-api/evas-plugin.h>
+#endif
+
+#if defined(DALI_NATIVE_BUFFER_PLUGIN)
+#include <dali/public-api/native-buffer-plugin.h>
+#endif
+
+#if defined(DALI_APPLICATION)
+#include <dali/public-api/application.h>
+#endif
+
+#include <dali/public-api/accessibility-manager.h>
+#include <dali/public-api/adaptor.h>
+#include <dali/public-api/clipboard.h>
+#include <dali/public-api/clipboard-event-notifier.h>
+#include <dali/public-api/color-controller.h>
+#include <dali/public-api/device-layout.h>
+#include <dali/public-api/drag-and-drop-detector.h>
+#include <dali/public-api/haptic-player.h>
+#include <dali/public-api/imf-manager.h>
+#include <dali/public-api/key.h>
+#include <dali/public-api/orientation.h>
+#include <dali/public-api/pixmap-image.h>
+#include <dali/public-api/render-surface.h>
+#include <dali/public-api/sound-player.h>
+#include <dali/public-api/style-change.h>
+#include <dali/public-api/style-monitor.h>
+#include <dali/public-api/timer.h>
+#include <dali/public-api/tts-player.h>
+#include <dali/public-api/virtual-keyboard.h>
+#include <dali/public-api/window.h>
+
+#include <dali/public-api/accessibility-action-handler.h>
+#include <dali/public-api/accessibility-gesture-handler.h>
+#include <dali/public-api/event-feeder.h>
+#include <dali/public-api/feedback-plugin.h>
+#include <dali/public-api/physical-keyboard.h>
+#include <dali/public-api/tilt-sensor.h>
+
+#endif //__DALI_H__
--- /dev/null
+#ifndef __DALI_DEVICE_LAYOUT_H__
+#define __DALI_DEVICE_LAYOUT_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/math/vector2.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+/**
+ * @brief The attributes of the screen on the device.
+ *
+ * An application can specify the base layout that they used by inputting the values in this
+ * structure and passing it to the Application or Adaptor class.
+ * @see Dali::Application::Application(* argc, char **argv[], DeviceLayout baseLayout)
+ * @see Dali::Adaptor::Adaptor(RenderSurface& surface, DeviceLayout baseLayout)
+ */
+struct DeviceLayout
+{
+public: // Construction & Destruction
+
+ /**
+ * @brief Default Constructor.
+ */
+ DeviceLayout();
+
+ /**
+ * @brief Create a DeviceLayout with specific parameters.
+ * @param[in] resolution The resolution of the screen the application is based upon.
+ * @param[in] screenSize The size of the screen the application is based upon.
+ * @param[in] dpi The DPI of the screen the application is based upon.
+ * @param[in] viewingDistance The default viewing distance of the screen the application is based upon.
+ */
+ DeviceLayout(Vector2 resolution, float screenSize, Vector2 dpi, float viewingDistance);
+
+ /**
+ * @brief Destructor.
+ */
+ ~DeviceLayout();
+
+public: // Data
+
+ Vector2 resolution; ///< Resolution (width and height) of the screen.
+ float screenSize; ///< Size of the screen in inches (diagonal size).
+ Vector2 dpi; ///< DPI (Dots per Inch) of the screen on the device (x & y).
+ float viewingDistance; ///< Average distance between the user and the device.
+
+public: // Defaults Layouts
+
+ /**
+ * @brief This is the default base layout that Dali will assume if no layout is passed in from the
+ * application.
+ *
+ * Resolution: 720.0f x 1280.0f
+ * Screen Size: 4.65f
+ * DPI: 316.0f x 316.0f
+ * Viewing Distance: 30.0f
+ */
+ static const DeviceLayout DEFAULT_BASE_LAYOUT;
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_DEVICE_LAYOUT_H__
--- /dev/null
+#ifndef __DALI_DRAG_AND_DROP_DETECTOR_H__
+#define __DALI_DRAG_AND_DROP_DETECTOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal-v2.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class DragAndDropDetector;
+}
+}
+
+/**
+ * @brief The DragAndDropDetector%s provides signals when draggable objects are dragged into our window.
+ * It provides signals for when the draggable object enters our window, moves around in our window,
+ * leaves our window and when it is finally dropped into our window.
+ * The basic usage is shown below:
+ *
+ * @code
+ *
+ * void Example()
+ * {
+ * DragAndDropDetector detector( window::GetDragAndDropDetector() );
+ *
+ * // Get notifications when the draggable item enters our window
+ * detector.EnteredSignal().Connect( &OnEntered );
+ *
+ * // Get notifications when the draggable item leaves our window
+ * detector.ExitedSignal().Connect( &OnExited );
+ *
+ * // Get notifications when the draggable item is moved within our window
+ * detector.MovedSignal().Connect( &OnMoved );
+ *
+ * // Get notifications when the draggable item is dropped
+ * detector.DroppedSignal().Connect( &OnDropped );
+ * }
+ *
+ * void OnEntered( DragAndDropDetector detector )
+ * {
+ * // Change mode as required
+ * }
+ *
+ * void OnExited( DragAndDropDetector detector )
+ * {
+ * // Change mode as required
+ * }
+ *
+ * void OnMoved( DragAndDropDetector detector )
+ * {
+ * // Query the new values
+ * std::cout << "Position = " << detector.GetCurrentScreenPosition() << std::endl;
+ * }
+ *
+ * void OnDropped( DragAndDropDetector detector )
+ * {
+ * // Query the new values
+ * std::cout << "Position = " << detector.GetCurrentScreenPosition() << ", Content = " << detector.GetContent() << std::endl;
+ * }
+ *
+ * @endcode
+ */
+class DragAndDropDetector : public BaseHandle
+{
+public:
+
+ // Typedefs
+
+ /**
+ * @brief Drag & Drop signal.
+ */
+ typedef SignalV2< void ( DragAndDropDetector ) > DragAndDropSignalV2;
+
+ // Signal Names
+ static const char* const SIGNAL_ENTERED;///< name "drag-and-drop-entered"
+ static const char* const SIGNAL_EXITED; ///< name "drag-and-drop-exited"
+ static const char* const SIGNAL_MOVED; ///< name "drag-and-drop-moved"
+ static const char* const SIGNAL_DROPPED;///< name "drag-and-drop-dropped"
+
+ /**
+ * @brief Create an uninitialized handle.
+ *
+ * This can be initialized by calling getting the detector from Dali::Window.
+ */
+ DragAndDropDetector();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~DragAndDropDetector();
+
+ /**
+ * @brief Returns the dropped content.
+ *
+ * @return A reference to the string representing the dropped content.
+ */
+ const std::string& GetContent() const;
+
+ /**
+ * @brief Returns the current position of the dragged object.
+ *
+ * This is the dropped position when an object is dropped.
+ * @return The current screen position.
+ */
+ Vector2 GetCurrentScreenPosition() const;
+
+public: // Signals
+
+ /**
+ * @brief This is emitted when a dragged object enters a DALi window.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallback( DragAndDropDetector detector );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ DragAndDropSignalV2& EnteredSignal();
+
+ /**
+ * @brief This is emitted when a dragged object leaves a DALi window.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallback( DragAndDropDetector detector );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ DragAndDropSignalV2& ExitedSignal();
+
+ /**
+ * @brief This is emitted when a dragged object is moved within the DALi window.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallback( DragAndDropDetector detector );
+ * @endcode
+ * This will be replaced by a property notification system once that is in place.
+ * @return The signal to connect to.
+ */
+ DragAndDropSignalV2& MovedSignal();
+
+ /**
+ * @brief This is emitted when a dragged object is dropped within a DALi window.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallback( DragAndDropDetector detector );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ DragAndDropSignalV2& DroppedSignal();
+
+public: // Not intended for application developers
+
+ /**
+ * @brief This constructor is used by DragAndDropDetector::Get().
+ *
+ * @param[in] detector A pointer to the drag and drop detector.
+ */
+ DragAndDropDetector( Internal::Adaptor::DragAndDropDetector* detector );
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_DRAG_AND_DROP_DETECTOR_H__
--- /dev/null
+#ifndef __DALI_EVAS_PLUGIN_H__
+#define __DALI_EVAS_PLUGIN_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+
+#include <dali/public-api/signals/dali-signal-v2.h>
+
+// Declare this forward declaration ourselves to remove unnecessary dependencies in
+// public headers.
+extern "C"
+{
+ struct _Evas_Object;
+ typedef struct _Evas_Object Evas_Object; ///< Forward declaration of Evas_Object
+}
+
+
+namespace Dali DALI_IMPORT_API
+{
+class Adaptor;
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class EvasPlugin;
+}
+}
+
+/**
+ * @brief Application class used by EFL applications that wish to use Dali.
+ *
+ * An EvasPlugin class object should be created by EFL application
+ * that wishes to use Dali. It provides a means for initialising the
+ * resources required by the Dali::Core.
+ *
+ * The EvasPlugin class emits several signals which the user can
+ * connect to. The user should not create any Dali objects in the main
+ * function and instead should connect to the Init signal of the
+ * EvasPlugin and create the Dali objects in the connected callback.
+ *
+ * SLP and EFL applications should follow the example below:
+ *
+ * @code
+ * void Created(EvasPlugin& evasPlugin)
+ * {
+ * // Create Dali components...
+ * // Can instantiate here, if required
+ * }
+ *
+ * void Resized(EvasPlugin& evasPlugin)
+ * {
+ * // Set size properties of Dali components
+ * // Set screen layout
+ * }
+ *
+ * int main (int argc, char **argv)
+ * {
+ * elm_init(&argc, &argv);
+ *
+ * Evas* e;
+ * Evas_Object* win, eo;
+ * win = elm_win_add(...);
+ * Dali::EvasPlugin evasPlugin = Dali::EvasPlugin(win);
+ * evasPlugin.InitSignal().Connect(&Created);
+ * evasPlugin.ResizeSignal().Connect(&Resized);
+ *
+ * eo = evasPlugin.GetEvasImageObject();
+ * evas_object_show(eo);
+ *
+ * // add eo to layout such as elm_box
+ *
+ * elm_run();
+ * }
+ * @endcode
+ *
+ * If required, you can also connect class member functions to a signal:
+ *
+ * @code
+ * MyEvasPlugin mep;
+ * mep.ResumeSignal().Connect(&app, &MyEvasPlugin::Resume);
+ * @endcode
+ */
+class EvasPlugin : public ConnectionTrackerInterface
+{
+public:
+
+ typedef SignalV2< void (EvasPlugin&) > EvasPluginSignalV2; ///< Generic evas plugin signal type
+
+public:
+
+ /**
+ * @brief This is the constructor for SLP EFL applications
+ * @param[in] parent A parent of new evas object
+ * @param[in] isTransparent Whether the object is transparent or not
+ * @param[in] initialWidth The initial width of Dali view port
+ * @param[in] initialHeight The initial height of Dali view port
+ */
+ EvasPlugin(Evas_Object* parent, bool isTransparent = false, unsigned int initialWidth = 1, unsigned int initialHeight = 1);
+
+ /**
+ * @brief Virtual destructor.
+ */
+ virtual ~EvasPlugin();
+
+public:
+
+ /**
+ * @brief Run Evas Plugin.
+ */
+ void Run();
+
+ /**
+ * @brief Pause Evas Plugin.
+ */
+ void Pause();
+
+ /**
+ * @brief Resume Evas Plugin.
+ */
+ void Resume();
+
+ /**
+ * @brief Stop Evas Plugin.
+ */
+ void Stop();
+
+ /**
+ * @brief This returns Evas_Object* which is created internally.
+ * @return Evas_Object* evas image object which is drawen by dali.
+ */
+ Evas_Object* GetEvasImageObject();
+
+ /**
+ * @brief This returns Evas_Object* which is created internally.
+ *
+ * Application should append this access object to custom focus chain for accessibility
+ *
+ * e.g. elm_object_focus_custom_chain_append(layout, dali_access_object, NULL);
+ *
+ * @return Evas_Object* elm access object which dali image object is registered.
+ */
+ Evas_Object* GetElmAccessObject();
+
+ /**
+ * @brief This returns Evas_Object* which is created internally.
+ *
+ * If application want to handle the keyboard focus among the efl and dali view part,
+ * application should set this object to efl layout instead of the evas image object from GetEvasImageObject()
+ * @return Evas_Object* evas object which can handle the focus internally. It is contained the image object.
+ */
+ Evas_Object* GetElmFocusObject();
+
+ /**
+ * @brief This returns the internal Adaptor instance.
+ *
+ * @return Adaptor* adaptor instance.
+ */
+ Dali::Adaptor* GetAdaptor();
+
+public: // Signals
+
+ /**
+ * @brief Signal to notify the client when the application is ready to be initialized.
+ * @return The signal
+ */
+ EvasPluginSignalV2& InitSignal();
+
+ /**
+ * @brief Signal to notify client when Dali has rendered at least one frame.
+ *
+ * The user should connect to this signal to be notified when Dali has started rendering
+ * and atleast one frame has been rendered.
+ * @return The signal
+ */
+ EvasPluginSignalV2& FirstRenderCompletedSignal();
+
+ /**
+ * @brief Signal to notify the user when the application is about to be terminated.
+ *
+ * @return The signal
+ */
+ EvasPluginSignalV2& TerminateSignal();
+
+ /**
+ * @brief Signal to notify the client when the adaptor is about to be paused.
+ *
+ * The user should connect to this signal if they need to perform any special
+ * activities when the application is about to be paused.
+ * @return The signal
+ */
+ EvasPluginSignalV2& PauseSignal();
+
+ /**
+ * @brief Signal to notify the client when the adpator has resumed.
+ *
+ * The user should connect to this signal if they need to perform any special
+ * activities when the application has resumed.
+ * @return The signal
+ */
+ EvasPluginSignalV2& ResumeSignal();
+
+ /**
+ * @brief Signal to notify the client when the evas object is resized.
+ * @return The signal
+ */
+ EvasPluginSignalV2& ResizeSignal();
+
+ /**
+ * @brief Signal to notify the client when the evas object get the keyboard focus.
+ * @return The signal
+ */
+ EvasPluginSignalV2& FocusedSignal();
+
+ /**
+ * @brief Signal to notify the client when the evas object lost the keyboard focus.
+ * @return The signal
+ */
+ EvasPluginSignalV2& UnFocusedSignal();
+
+protected:
+ /**
+ * @copydoc ConnectionTrackerInterface::SignalConnected
+ */
+ virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback );
+
+ /**
+ * @copydoc ConnectionTrackerInterface::SignalDisconnected
+ */
+ virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback );
+
+ /**
+ * @copydoc ConnectionTrackerInterface::GetConnectionCount
+ */
+ virtual std::size_t GetConnectionCount() const;
+
+private:
+
+ // Undefined
+ EvasPlugin(const EvasPlugin&);
+ EvasPlugin& operator=(EvasPlugin&);
+
+private:
+
+ Internal::Adaptor::EvasPlugin *mImpl; ///< Pointer to Implementation
+ friend class Internal::Adaptor::EvasPlugin;
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_EVAS_PLUGIN_H__
--- /dev/null
+#ifndef __DALI_EVENT_FEEDER_H_
+#define __DALI_EVENT_FEEDER_H_
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+struct KeyEvent;
+struct MouseWheelEvent;
+struct TouchPoint;
+
+namespace EventFeeder
+{
+
+/**
+ * Feed a touch point to the adaptor.
+ *
+ * @param[in] point touch point
+ * @param[in] timeStamp time value of event
+ *
+ * @note For testing/automation purposes only.
+ */
+void FeedTouchPoint( TouchPoint& point, int timeStamp );
+
+/**
+ * Feed a mouse wheel event to the adaptor.
+ *
+ * @param[in] wheelEvent mouse wheel event
+ *
+ * @note For testing/automation purposes only.
+ */
+void FeedWheelEvent( MouseWheelEvent& wheelEvent );
+
+/**
+ * Feed a key event to the adaptor.
+ *
+ * @param[in] keyEvent The key event holding the key information.
+ *
+ * @note For testing/automation purposes only.
+ */
+void FeedKeyEvent( KeyEvent& keyEvent );
+
+} // namespace EventFeeder
+
+} // namespace Dali
+
+#endif // __DALI_EVENT_FEEDER_H_
--- /dev/null
+#ifndef __DALI_FEEDBACK_PLUGIN_H__
+#define __DALI_FEEDBACK_PLUGIN_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+/**
+ * FeedbackPlugin is an abstract interface, used by Dali-adaptor to access haptic and audio feedback.
+ * A concrete implementation must be created for each platform and provided as a dynamic library which
+ * will be loaded at run time by the adaptor.
+ */
+class FeedbackPlugin
+{
+public:
+
+ typedef void (*SoundStopCallBack)( void* ptr );
+
+ /**
+ * Destructor.
+ */
+ virtual ~FeedbackPlugin()
+ {
+ }
+
+ /**
+ * Plays vibration in predefined patterns.
+ * @param[in] filePath Path to the file containing the effect.
+ */
+ virtual void PlayHaptic( const std::string& filePath ) = 0;
+
+ /**
+ * Plays a monotone vibration.
+ * @param[in] duration The duration of the vibration.
+ */
+ virtual void PlayHapticMonotone( unsigned int duration ) = 0;
+
+ /**
+ * Stops the currently playing vibration effects.
+ */
+ virtual void StopHaptic() = 0;
+
+ /**
+ * Plays a sound file.
+ * @param[in] fileName Path to the sound file to play.
+ * @return A handle which can be used to stop the sound playback.
+ */
+ virtual int PlaySound( const std::string& fileName ) = 0;
+
+ /**
+ * Stops a currently playing sound.
+ * @param[in] handle A handle to the currently playing sound.
+ */
+ virtual void StopSound( int handle ) = 0;
+
+ /**
+ * Plays a feedback pattern.
+ * @param[in] type The type of feedback.
+ * @param[in] pattern The ID of the pattern to play.
+ */
+ virtual void PlayFeedbackPattern( int type, int pattern ) = 0;
+
+ // Types for plugin factories
+
+ /**
+ * Function pointer called in adaptor to create a feedback plugin instance.
+ * @param [in] pluginName name of the plugin to load.
+ * @return Pointer to the newly created plugin object
+ */
+ typedef FeedbackPlugin* CreateFeedbackPlugin( void );
+
+}; // class FeedbackPlugin
+
+} // namespace Dali
+
+#endif // __DALI_FEEDBACK_PLUGIN_H__
--- /dev/null
+evas_plugin_public_api_header_files = \
+ $(adaptor_public_api_dir)/evas-plugin.h
+
+native_buffer_plugin_public_api_header_files = \
+ $(adaptor_public_api_dir)/native-buffer-plugin.h
+
+livebox_plugin_public_api_header_files = \
+ $(adaptor_public_api_dir)/livebox-plugin.h
+
+public_api_header_files = \
+ $(adaptor_public_api_dir)/accessibility-manager.h \
+ $(adaptor_public_api_dir)/adaptor.h \
+ $(adaptor_public_api_dir)/clipboard-event-notifier.h \
+ $(adaptor_public_api_dir)/clipboard.h \
+ $(adaptor_public_api_dir)/color-controller.h \
+ $(adaptor_public_api_dir)/device-layout.h \
+ $(adaptor_public_api_dir)/drag-and-drop-detector.h \
+ $(adaptor_public_api_dir)/haptic-player.h \
+ $(adaptor_public_api_dir)/imf-manager.h \
+ $(adaptor_public_api_dir)/key.h \
+ $(adaptor_public_api_dir)/orientation.h \
+ $(adaptor_public_api_dir)/pixmap-image.h \
+ $(adaptor_public_api_dir)/render-surface.h \
+ $(adaptor_public_api_dir)/sound-player.h \
+ $(adaptor_public_api_dir)/style-change.h \
+ $(adaptor_public_api_dir)/style-monitor.h \
+ $(adaptor_public_api_dir)/timer.h \
+ $(adaptor_public_api_dir)/tts-player.h \
+ $(adaptor_public_api_dir)/virtual-keyboard.h \
+ $(adaptor_public_api_dir)/window.h \
+ $(adaptor_public_api_dir)/accessibility-action-handler.h \
+ $(adaptor_public_api_dir)/accessibility-gesture-handler.h \
+ $(adaptor_public_api_dir)/event-feeder.h \
+ $(adaptor_public_api_dir)/feedback-plugin.h \
+ $(adaptor_public_api_dir)/physical-keyboard.h \
+ $(adaptor_public_api_dir)/tilt-sensor.h
+
+public_api_application_header_files = \
+ $(adaptor_public_api_dir)/application.h
+
+adaptor_dali_header_file = \
+ $(adaptor_public_api_dir)/dali.h
--- /dev/null
+#ifndef __DALI_HAPTIC_PLAYER_H__
+#define __DALI_HAPTIC_PLAYER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-handle.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class HapticPlayer;
+}
+}
+
+/**
+ * @brief Plays haptic effects.
+ */
+class HapticPlayer : public BaseHandle
+{
+public:
+
+ /**
+ * @brief Create an uninitialized handle.
+ *
+ * This can be initialized by calling HapticPlayer::Get().
+ */
+ HapticPlayer();
+
+ /**
+ * @brief Create an initialized handle to the HapticPlayer.
+ *
+ * @return A handle to a newly allocated Dali resource.
+ */
+ static HapticPlayer Get();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~HapticPlayer();
+
+ /**
+ * @brief Plays a monotone vibration.
+ * @param[in] duration The duration of the vibration.
+ */
+ void PlayMonotone(unsigned int duration);
+
+ /**
+ * @brief Plays vibration in predefined patterns.
+ * @param[in] filePath Path to the file containing the effect.
+ */
+ void PlayFile(const std::string filePath);
+
+ /**
+ * @brief Stops the currently playing vibration effects.
+ */
+ void Stop();
+
+public: // Not intended for application developers
+
+ /**
+ * @brief This constructor is used by HapticPlayer::Get().
+ * @param[in] hapticPlayer A pointer to the haptic player.
+ */
+ HapticPlayer( Internal::Adaptor::HapticPlayer* hapticPlayer );
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_HAPTIC_PLAYER_H__
--- /dev/null
+#ifndef IMFMANAGER_H
+#define IMFMANAGER_H
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal-v2.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class ImfManager;
+}
+}
+
+// TODO: Temporary patch to hidden ecore dependency. Must fix it.
+typedef void* ImfContext;
+
+/**
+ * @brief The ImfManager class
+ *
+ * Specifically manages the ecore input method framework which enables the virtual or hardware keyboards.
+ */
+class ImfManager : public BaseHandle
+{
+public:
+
+ /**
+ * @brief Events that are generated by the IMF.
+ */
+ enum ImfEvent
+ {
+ VOID, ///< No event
+ PREEDIT, ///< Pre-Edit changed
+ COMMIT, ///< Commit recieved
+ DELETESURROUNDING, ///< Event to delete a range of characters from the string
+ GETSURROUNDING ///< Event to query string and cursor position
+ };
+
+ /**
+ * @brief This structure is used to pass on data from the IMF regarding predictive text.
+ */
+ struct ImfEventData
+ {
+ /**
+ * @brief Default Constructor.
+ */
+ ImfEventData()
+ : eventName( VOID ),
+ predictiveString(""),
+ cursorOffset( 0 ),
+ numberOfChars ( 0 )
+ {
+ };
+
+ /**
+ * @brief Constructor
+ *
+ * @param[in] aEventName The name of the event from the IMF.
+ * @param[in] aPredictiveString The pre-edit or commit string.
+ * @param[in] aCursorOffset Start position from the current cursor position to start deleting characters.
+ * @param[in] aNumberOfChars The number of characters to delete from the cursorOffset.
+ */
+ ImfEventData(ImfEvent aEventName, const std::string& aPredictiveString, int aCursorOffset,int aNumberOfChars )
+ : eventName(aEventName), predictiveString(aPredictiveString), cursorOffset( aCursorOffset ), numberOfChars( aNumberOfChars )
+ {
+ }
+
+ // Data
+ ImfEvent eventName; ///< The name of the event from the IMF.
+ std::string predictiveString; ///< The pre-edit or commit string.
+ int cursorOffset; ///< Start position from the current cursor position to start deleting characters.
+ int numberOfChars; ///< number of characters to delete from the cursorOffset.
+ };
+
+ /**
+ * @brief Data required by IMF from the callback
+ */
+ struct ImfCallbackData
+ {
+ /**
+ * @brief Constructor
+ */
+ ImfCallbackData( )
+ : update( false ), cursorPosition( 0 ), preeditResetRequired ( false )
+ {
+ }
+
+ /**
+ * @brief Constructor
+ * @param[in] aUpdate True if cursor position needs to be updated
+ * @param[in] aCursorPosition new position of cursor
+ * @param[in] aCurrentText current text string
+ * @param[in] aPreeditResetRequired flag if preedit reset is required.
+ */
+ ImfCallbackData(bool aUpdate, int aCursorPosition, std::string aCurrentText, bool aPreeditResetRequired )
+ : update(aUpdate), cursorPosition(aCursorPosition), currentText( aCurrentText ), preeditResetRequired( aPreeditResetRequired )
+ {
+ }
+
+ bool update; ///< if cursor position needs to be updated
+ int cursorPosition; ///< new position of cursor
+ std::string currentText; ///< current text string
+ bool preeditResetRequired; ///< flag if preedit reset is required.
+ };
+
+ typedef SignalV2< void (ImfManager&) > ImfManagerSignalV2; ///< Keyboard actived signal
+
+ typedef SignalV2< ImfCallbackData ( ImfManager&, const ImfEventData& ) > ImfEventSignalV2; ///< keyboard events
+
+public:
+
+ /**
+ * @brief Retrieve a handle to the instance of ImfManager.
+ * @return A handle to the ImfManager.
+ */
+ static ImfManager Get();
+
+ /**
+ * @brief Get the current imf context.
+ * @return current imf context.
+ */
+ ImfContext GetContext();
+
+ /**
+ * @brief Activate the IMF.
+ *
+ * It means that the text editing is started at somewhere.
+ * If the H/W keyboard isn't connected then it will show the virtual keyboard.
+ */
+ void Activate();
+
+ /**
+ * @brief Deactivate the IMF.
+ *
+ * It means that the text editing is finished at somewhere.
+ */
+ void Deactivate();
+
+ /**
+ * @brief Get the restoration status, which controls if the keyboard is restored after the focus lost then regained.
+ *
+ * If true then keyboard will be restored (activated) after focus is regained.
+ * @return restoration status.
+ */
+ bool RestoreAfterFocusLost() const;
+
+ /**
+ * @brief Set status whether the IMF has to restore the keyboard after losing focus.
+ *
+ * @param[in] toggle True means that keyboard should be restored after focus lost and regained.
+ */
+ void SetRestoreAferFocusLost( bool toggle );
+
+ /**
+ * @brief Send message reset the pred-edit state / imf module.
+ *
+ * Used to interupt pre-edit state maybe due to a touch input.
+ */
+ void Reset();
+
+ /**
+ * @brief Notifies IMF context that the cursor position has changed, required for features like auto-capitalisation.
+ */
+ void NotifyCursorPosition();
+
+ /**
+ * @brief Sets cursor position stored in VirtualKeyboard, this is required by the IMF context.
+ *
+ * @param[in] cursorPosition position of cursor
+ */
+ void SetCursorPosition( unsigned int cursorPosition );
+
+ /**
+ * @brief Gets cursor position stored in VirtualKeyboard, this is required by the IMF context.
+ *
+ * @return current position of cursor
+ */
+ int GetCursorPosition();
+
+ /**
+ * @brief Method to store the string required by the IMF, this is used to provide predictive word suggestions.
+ *
+ * @param[in] text The text string surrounding the current cursor point.
+ */
+ void SetSurroundingText( std::string text );
+
+ /**
+ * @brief Gets current text string set within the IMF manager, this is used to offer predictive suggestions.
+ *
+ * @return current position of cursor
+ */
+ std::string GetSurroundingText();
+
+public:
+
+ // Signals
+
+ /**
+ * @brief This is emitted when the virtual keyboard is connected to or the hardware keyboard is activated.
+ *
+ * @return The IMF Activated signal.
+ */
+ ImfManagerSignalV2& ActivatedSignal();
+
+ /**
+ * @brief This is emitted when the IMF manager receives an event from the IMF.
+ *
+ * @return The Event signal containing the event data.
+ */
+ ImfEventSignalV2& EventReceivedSignal();
+
+ // Construction & Destruction
+
+ /**
+ * @brief Constructor.
+ */
+ ImfManager();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~ImfManager();
+
+ /**
+ * @brief This constructor is used by ImfManager::Get().
+ *
+ * @param[in] imfManager A pointer to the imf Manager.
+ */
+ ImfManager( Internal::Adaptor::ImfManager* imfManager );
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // IMFMANAGER_H
--- /dev/null
+#ifndef __DALI_KEY_H__
+#define __DALI_KEY_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+
+#include <dali/public-api/events/key-event.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+/**
+ * @brief Mapping of keyboard and mouse button event keycodes to platform specific codes.
+ *
+ * For tizen the X Server Keycode is used as reference, unless it's over ridden
+ * in utilX.h in which case the values are based on utilX.h
+ */
+
+typedef int KEY;
+
+extern const KEY DALI_KEY_INVALID;
+extern const KEY DALI_KEY_ESCAPE;
+extern const KEY DALI_KEY_BACK;
+extern const KEY DALI_KEY_CAMERA;
+extern const KEY DALI_KEY_CONFIG;
+extern const KEY DALI_KEY_POWER;
+extern const KEY DALI_KEY_PAUSE;
+extern const KEY DALI_KEY_CANCEL;
+extern const KEY DALI_KEY_PLAY_CD;
+extern const KEY DALI_KEY_STOP_CD;
+extern const KEY DALI_KEY_PAUSE_CD;
+extern const KEY DALI_KEY_NEXT_SONG;
+extern const KEY DALI_KEY_PREVIOUS_SONG;
+extern const KEY DALI_KEY_REWIND;
+extern const KEY DALI_KEY_FASTFORWARD;
+extern const KEY DALI_KEY_MEDIA;
+extern const KEY DALI_KEY_PLAY_PAUSE;
+extern const KEY DALI_KEY_MUTE;
+extern const KEY DALI_KEY_SEND;
+extern const KEY DALI_KEY_SELECT;
+extern const KEY DALI_KEY_END;
+extern const KEY DALI_KEY_MENU;
+extern const KEY DALI_KEY_HOME;
+extern const KEY DALI_KEY_HOMEPAGE;
+extern const KEY DALI_KEY_WEBPAGE;
+extern const KEY DALI_KEY_MAIL;
+extern const KEY DALI_KEY_SCREENSAVER;
+extern const KEY DALI_KEY_BRIGHTNESS_UP;
+extern const KEY DALI_KEY_BRIGHTNESS_DOWN;
+extern const KEY DALI_KEY_SOFT_KBD;
+extern const KEY DALI_KEY_QUICK_PANEL;
+extern const KEY DALI_KEY_TASK_SWITCH;
+extern const KEY DALI_KEY_APPS;
+extern const KEY DALI_KEY_SEARCH;
+extern const KEY DALI_KEY_VOICE;
+extern const KEY DALI_KEY_LANGUAGE;
+extern const KEY DALI_KEY_VOLUME_UP;
+extern const KEY DALI_KEY_VOLUME_DOWN;
+
+/**
+ * @brief Check if a key event is for a specific DALI KEY.
+ *
+ * @param keyEvent reference to a keyEvent structure
+ * @param daliKey dali key enum
+ * @return true if the key is matched, false if not
+ */
+bool IsKey( const KeyEvent& keyEvent, KEY daliKey);
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_KEY_H__
--- /dev/null
+#ifndef __DALI_LIVEBOX_H__
+#define __DALI_LIVEBOX_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDS
+#include <boost/function.hpp>
+#include <string>
+#include <dali/public-api/math/rect.h>
+
+// INTERNAL INCLUDES
+#include "device-layout.h"
+#include "style-monitor.h"
+
+
+namespace Dali DALI_IMPORT_API
+{
+typedef Dali::Rect<int> PositionSize;
+
+/**
+* Livebox's size types
+* It refers "livebox-service.h"
+*/
+enum LiveboxSizeType
+{
+ LIVEBOX_SIZE_TYPE_1x1 = 0x0001,
+ LIVEBOX_SIZE_TYPE_2x1 = 0x0002,
+ LIVEBOX_SIZE_TYPE_2x2 = 0x0004,
+ LIVEBOX_SIZE_TYPE_4x1 = 0x0008,
+ LIVEBOX_SIZE_TYPE_4x2 = 0x0010,
+ LIVEBOX_SIZE_TYPE_4x3 = 0x0020,
+ LIVEBOX_SIZE_TYPE_4x4 = 0x0040,
+ LIVEBOX_SIZE_TYPE_EASY_1x1 = 0x0100,
+ LIVEBOX_SIZE_TYPE_EASY_3x1 = 0x0200,
+ LIVEBOX_SIZE_TYPE_EASY_3x3 = 0x0400,
+ LIVEBOX_SIZE_TYPE_UNKNOWN = 0xFFFF,
+};
+
+struct GlanceBarEventInfo
+{
+ std::string emission;
+ std::string source;
+
+ struct
+ {
+ double x;
+ double y;
+ int down;
+ } pointer; ///< touch information for script
+
+ struct
+ {
+ double sx;
+ double sy;
+ double ex;
+ double ey;
+ } part; ///<part information for script
+};
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+
+class LiveboxPlugin;
+}
+}
+
+/**
+ * An LiveboxPlugin class object should be created by every livebox
+ * that wishes to use Dali. It provides a means for initialising the
+ * resources required by the Dali::Core.
+ *
+ * The LiveboxPlugin class emits several signals which the user can
+ * connect to. The user should not create any Dali objects in the main
+ * function and instead should connect to the Init signal of the
+ * LiveboxPlugin and create the Dali objects in the connected callback.
+ *
+ * SLP and Linux Liveboxs should follow the example below:
+ *
+ * @code
+ * void CreateProgram(LiveboxPlugin& livebox)
+ * {
+ * // Create Dali components...
+ * // Can instantiate here, if required
+ * }
+ *
+ * int main (int argc, char **argv)
+ * {
+ * LiveboxPlugin livebox(&argc, &argv);
+ * livebox.InitSignal().Connect(&CreateProgram);
+ * livebox.Run();
+ * }
+ * @endcode
+ *
+ * If required, you can also connect class member functions to a signal:
+ *
+ * @code
+ * MyLivebox livebox;
+ * livebox.SignalResumed().Connect(&app, &MyLivebox::OnResumed);
+ * @endcode
+ */
+class LiveboxPlugin
+{
+public:
+
+ typedef SignalV2< void (LiveboxPlugin&) > LiveboxPluginSignalV2;
+
+public:
+
+ /**
+ * This is the constructor for Linux & SLP liveboxs.
+ * @param argc A pointer to the number of arguments
+ * @param argv A pointer the the argument list
+ * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
+ */
+ LiveboxPlugin( int* argc, char **argv[] );
+
+ /**
+ * This is the constructor for Linux & SLP liveboxs with a name
+ * @param argc A pointer to the number of arguments
+ * @param argv A pointer the the argument list
+ * @param name A name of livebox
+ * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
+ */
+ LiveboxPlugin( int* argc, char **argv[], const std::string& name );
+
+ /**
+ * This is the constructor for Linux & SLP liveboxs when a layout for the livebox is specified.
+ * @param argc A pointer to the number of arguments
+ * @param argv A pointer the the argument list
+ * @param baseLayout The base layout that the livebox has been written for
+ */
+ LiveboxPlugin( int* argc, char **argv[], const DeviceLayout& baseLayout );
+
+ /**
+ * This is the constructor for Linux & SLP liveboxs with a name and when a layout for the livebox is specified.
+ * @param argc A pointer to the number of arguments
+ * @param argv A pointer the the argument list
+ * @param name A name of livebox
+ * @param baseLayout The base layout that the livebox has been written for
+ */
+ LiveboxPlugin( int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout );
+
+ /**
+ * Virtual destructor
+ */
+ virtual ~LiveboxPlugin();
+
+public:
+
+ /**
+ * Set title string of the livebox
+ * @param[in] title title string
+ */
+ void SetTitle(const std::string& title);
+
+ /**
+ * Set content string of the livebox
+ * @param[in] content content string
+ */
+ void SetContent(const std::string& content);
+
+ /**
+ * Get glance bar's geometry information
+ * x, y mean arrow position
+ * w, h mean glance size
+ * User can use this method in the glance-created signal handler
+ * @return PositionSize structure for glance bar information. {-1, -1, -1, -1} means invalid status for glance
+ */
+ const PositionSize& GetGlanceBarGeometry() const;
+
+ /**
+ * Get glance bar's event information
+ * @return GlanceBarEventInfo structure for glance bar event
+ */
+ const GlanceBarEventInfo& GetGlanceBarEventInfo() const;
+
+ /**
+ * Get current size type of livebox
+ */
+ LiveboxSizeType GetLiveboxSizeType() const;
+
+ /**
+ * This starts the livebox providing.
+ */
+ void Run();
+
+ /**
+ * This quits the livebox providing.
+ */
+ void Quit();
+
+ /**
+ * Ensures that the function passed in is called from the main loop when it is idle.
+ *
+ * A callback of the following type may be used:
+ * @code
+ * void MyFunction();
+ * @endcode
+ *
+ * @param[in] callBack The function to call.
+ * @return true if added successfully, false otherwise
+ */
+ bool AddIdle(boost::function<void(void)> callBack);
+
+ /**
+ * Returns the local thread's instance of the LiveboxPlugin class.
+ * @return A reference to the local thread's LiveboxPlugin class instance.
+ * @pre The LiveboxPlugin class has been initialised.
+ * @note This is only valid in the main thread.
+ */
+ static LiveboxPlugin& Get();
+
+public: // Signals
+
+ /**
+ * The user should connect to this signal to determine when they should initialise
+ * their livebox
+ */
+ LiveboxPluginSignalV2& InitializedSignal();
+
+ /**
+ * The user should connect to this signal to determine when they should terminate
+ * their livebox
+ */
+ LiveboxPluginSignalV2& TerminatedSignal();
+
+ /**
+ * The user should connect to this signal if they need to perform any special
+ * activities when the livebox is about to be paused.
+ */
+ LiveboxPluginSignalV2& PausedSignal();
+
+ /**
+ * The user should connect to this signal if they need to perform any special
+ * activities when the livebox has resumed.
+ */
+ LiveboxPluginSignalV2& ResumedSignal();
+
+ /**
+ * This signal is emitted when the surface the livebox is rendering on is resized.
+ */
+ LiveboxPluginSignalV2& ResizedSignal();
+
+ /**
+ * This signal is emitted when the glance bar popup was created.
+ */
+ LiveboxPluginSignalV2& GlanceCreatedSignal();
+
+ /**
+ * This signal is emitted when the glance bar popup was destroyed.
+ */
+ LiveboxPluginSignalV2& GlanceDestroyedSignal();
+
+ /**
+ * This signal is emitted when the glance bar popup was touched.
+ */
+ LiveboxPluginSignalV2& GlanceTouchedSignal();
+
+ /**
+ * This signal is emitted when the glance bar popup was moved.
+ */
+ LiveboxPluginSignalV2& GlanceMovedSignal();
+
+ /**
+ * This signal is emitted when the glance bar popup was got script event callback.
+ * If application registered the edje file for glance bar,
+ * this signal will be emitted instead of SignalGlanceTouched.
+ * Application can get the event information by using GetGlanceBarEventInfo()
+ */
+ LiveboxPluginSignalV2& GlanceScriptEventSignal();
+
+ /**
+ * This signal is emitted when the language is changed on the device.
+ */
+ LiveboxPluginSignalV2& LanguageChangedSignal();
+
+private:
+
+ // Undefined
+ LiveboxPlugin(const LiveboxPlugin&);
+ LiveboxPlugin& operator=(const LiveboxPlugin&);
+
+private:
+
+ Internal::Adaptor::LiveboxPlugin *mImpl;
+ friend class Internal::Adaptor::LiveboxPlugin;
+};
+
+} // namespace Dali
+
+#endif // __DALI_LIVEBOX_H__
+
--- /dev/null
+#ifndef __DALI_NATIVE_BUFFER_PLUGIN_H__
+#define __DALI_NATIVE_BUFFER_PLUGIN_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <native-buffer-pool.h>
+#include <boost/function.hpp>
+
+#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/math/vector2.h>
+#include "render-surface.h"
+#include "device-layout.h"
+
+namespace Dali DALI_IMPORT_API
+{
+
+class Adaptor;
+
+namespace Internal DALI_INTERNAL
+{
+
+namespace Adaptor
+{
+
+class NativeBufferPlugin;
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+/**
+ * @brief Used by Tizen applications that wish to capture Dali output in a buffer.
+ *
+ * A NativeBufferPlugin class object should be created by Tizen application
+ * that wish to use Dali, capturing it's output using the Native Buffer Provider API.
+ * It provides a means for initialising the resources required by the Dali::Core.
+ *
+ * The NativeBufferPlugin class emits several signals which the user may
+ * connect to. The user should not create any Dali objects in the main()
+ * function and instead should connect to the InitSignal of the
+ * NativeBufferPlugin and create DALi objects in the signal handler.
+ *
+ * Tizen applications should follow the example below:
+ *
+ * @code
+ * void OnConsumeTimerCallback()
+ * {
+ * native_buffer* buffer = nbPlugin.GetNativeBufferFromOutput();
+ * if(buffer != NULL)
+ * {
+ * // Consume the buffer
+ * }
+ * // return back the buffer to plugin
+ * AddNativeBufferToInput(buffer);
+ * }
+ *
+ * void Created(NativeBufferPlugin& nbPlugin)
+ * {
+ * // Create Dali components...
+ * // Can instantiate here, if required
+ * mTimer = Dali::Timer::New(1000/30); // 30fps
+ * mTimer.TickSignal().Connect(this, &OnConsumeTimerCallback);
+ * mTimer.Start();
+ * }
+ *
+ * void Resized(NativeBufferPlugin& nbPlugin)
+ * {
+ * // Set size properties of Dali components
+ * // Set screen layout
+ * }
+ *
+ * int main (int argc, char **argv)
+ * {
+ * Dali::NativeBufferPlugin nbPlugin( 640, 480, false, 2, RENDER_30FPS );
+ * nbPlugin.InitSignal().Connect(&Created);
+ * nbPlugin.ResizeSignal().Connect(&Resized);
+ * nbPlugin.Run();
+ * }
+ * @endcode
+ */
+class NativeBufferPlugin
+{
+public:
+
+ typedef SignalV2< void (NativeBufferPlugin&) > NativeBufferPluginSignalV2; ///< Generic native buffer signal type
+
+public:
+
+ /**
+ * @brief This is the constructor for Tizen applications.
+ * @param[in] initialWidth The initial width of Dali view port
+ * @param[in] initialHeight The initial height of Dali view port
+ * @param[in] isTransparent Whether the surface will be transparent or not
+ * @param[in] maxBufferCount The maximum number of buffers to render
+ * @param[in] mode The rendering mode to decide frame rate
+ * @param[in] baseLayout The base layout that the application has been written for
+ */
+ NativeBufferPlugin( unsigned int initialWidth, unsigned int initialHeight, bool isTransparent = false, unsigned int maxBufferCount = 2, RenderSurface::RenderMode mode = RenderSurface::RENDER_60FPS, const DeviceLayout& baseLayout = DeviceLayout::DEFAULT_BASE_LAYOUT);
+
+ /**
+ * @brief Virtual destructor.
+ */
+ virtual ~NativeBufferPlugin();
+
+public:
+
+ /**
+ * @brief Run the NativeBufferPlugin.
+ */
+ void Run();
+
+ /**
+ * @brief Pause the NativeBufferPlugin.
+ */
+ void Pause();
+
+ /**
+ * @brief Resume the NativeBufferPlugin.
+ */
+ void Resume();
+
+ /**
+ * @brief Stop the NativeBufferPlugin.
+ */
+ void Stop();
+
+ /**
+ * @brief Get the internal Adaptor instance.
+ * @return A pointer to the internal adaptor instance.
+ */
+ Dali::Adaptor* GetAdaptor();
+
+ /**
+ * @brief Get the native buffer object which contain rendered result.
+ *
+ * Application should return back the buffer object to plugin by using AddNativeBufferToInput().
+ * @return A pointer to the native buffer object.
+ * @note do not destroy the native-buffer returned from this plugin.
+ */
+ native_buffer* GetNativeBufferFromOutput();
+
+ /**
+ * @brief Add the native buffer object which was consumed in application.
+ *
+ * The added buffer will be re-used with render target
+ * @param nativeBuffer A pointer to the native buffer object.
+ * @return True if the operation is successful
+ * @pre the nativeBuffer should be got by GetNativeBufferFromOutput()
+ */
+ bool AddNativeBufferToInput(native_buffer* nativeBuffer);
+
+ /**
+ * @brief Get number of native buffers in pool.
+ * @return vector2 which has input buffer count and output buffer count
+ */
+ Vector2 GetBufferCount();
+
+ /**
+ * @brief Change surface size.
+ *
+ * NOT YET SUPPORTED
+ * @param width The width of target size
+ * @param height The height of target size
+ */
+ void ChangeSurfaceSize(unsigned int width, unsigned int height);
+
+public: // Signals
+
+ /**
+ * @brief Signal to notify the client when the application is ready to be initialized.
+ * @return The signal
+ */
+ NativeBufferPluginSignalV2& InitSignal();
+
+ /**
+ * @brief Signal to notify the user when the application is about to be terminated.
+ * @return The signal
+ */
+ NativeBufferPluginSignalV2& TerminateSignal();
+
+ /**
+ * @brief Signal to notify the client when the adaptor is about to be paused.
+ *
+ * The user should connect to this signal if they need to perform any special
+ * activities when the application is about to be paused.
+ * @return The signal
+ */
+ NativeBufferPluginSignalV2& PauseSignal();
+
+ /**
+ * @brief Signal to notify the client when the adpator has resumed.
+ *
+ * The user should connect to this signal if they need to perform any special
+ * activities when the application has resumed.
+ * @return The signal
+ */
+ NativeBufferPluginSignalV2& ResumeSignal();
+
+ /**
+ * @brief Signal to notify the client when Dali has rendered at least one frame.
+ *
+ * The user should connect to this signal to be notified when Dali has started rendering
+ * and atleast one frame has been rendered.
+ * @return The signal
+ */
+ NativeBufferPluginSignalV2& FirstRenderCompletedSignal();
+
+ /**
+ * @brief Signal to notify the client when Dali has rendered one frame
+ * @return The signal
+ */
+ NativeBufferPluginSignalV2& RenderSignal();
+
+private:
+
+ // Undefined copy constructor
+ NativeBufferPlugin(const NativeBufferPlugin&);
+
+ // Undefined assignment operator
+ NativeBufferPlugin& operator=(NativeBufferPlugin&);
+
+private:
+
+ Internal::Adaptor::NativeBufferPlugin *mImpl; ///< Pointer to implementation
+ friend class Internal::Adaptor::NativeBufferPlugin;
+
+}; // class NativeBufferPlugin
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_NATIVE_BUFFER_PLUGIN_H__
--- /dev/null
+#ifndef __DALI_ORIENTATION_H__
+#define __DALI_ORIENTATION_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+
+#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/object/base-handle.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class Orientation;
+}
+}
+
+/**
+ * @brief Orientation allows the user to determine the orientation of the device.
+ *
+ * A signal is emitted whenever the orientation changes.
+ * Dali applications have full control over visual layout when the device is rotated
+ * i.e. the application developer decides which UI controls to rotate, if any.
+ */
+class Orientation : public BaseHandle
+{
+public:
+
+ typedef SignalV2< void (Orientation) > OrientationSignalV2; ///< Orientation changed signal type
+
+ /**
+ * @brief Create an unintialized handle.
+ *
+ * This can be initialized by calling Dali::Application::GetOrientation()
+ */
+ Orientation();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~Orientation();
+
+ /**
+ * @copydoc Dali::BaseHandle::operator=
+ */
+ using BaseHandle::operator=;
+
+
+ /**
+ * @brief Returns the orientation of the device in degrees.
+ *
+ * This is one of four discrete values, in degrees clockwise: 0, 90, 180, & 270
+ * For a device with a portrait form-factor:
+ * 0 indicates that the device is in the "normal" portrait orientation.
+ * 90 indicates that device has been rotated clockwise, into a landscape orientation.
+ * @return The orientation in degrees clockwise.
+ */
+ int GetDegrees() const;
+
+ /**
+ * @brief Returns the orientation of the device in radians.
+ *
+ * This is one of four discrete values, in radians clockwise: 0, PI/2, PI, & 3xPI/2
+ * For a device with a portrait form-factor:
+ * 0 indicates that the device is in the "normal" portrait orientation.
+ * PI/2 indicates that device has been rotated clockwise, into a landscape orientation.
+ * @return The orientation in radians clockwise.
+ */
+ float GetRadians() const;
+
+ /**
+ * @brief The user should connect to this signal so that they can be notified whenever
+ * the orientation of the device changes.
+ *
+ * @return The orientation change signal.
+ */
+ OrientationSignalV2& ChangedSignal();
+
+public: // Not intended for application developers
+ /**
+ * @brief This constructor is used by Dali::Application::GetOrientation().
+ *
+ * @param[in] orientation A pointer to the orientation object
+ */
+ explicit DALI_INTERNAL Orientation( Internal::Adaptor::Orientation* orientation );
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_ORIENTATION_H__
--- /dev/null
+#ifndef __DALI_PHYSICAL_KEYBOARD_H__
+#define __DALI_PHYSICAL_KEYBOARD_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal-v2.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class PhysicalKeyboard;
+}
+}
+
+/**
+ * This is a handle to a physical keyboard connected to the device.
+ */
+class PhysicalKeyboard : public BaseHandle
+{
+public:
+
+ typedef SignalV2< void (PhysicalKeyboard) > Signal;
+
+public:
+
+ /**
+ * Create an uninitialized PhysicalKeyboard handle; this can be initialized with GetKeyboard()
+ * Calling member functions with an uninitialized Dali::Object is not allowed.
+ */
+ PhysicalKeyboard();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~PhysicalKeyboard();
+
+ /**
+ * Gets a handle to the physical keyboard.
+ * @return A handle to the physical keyboard.
+ */
+ static PhysicalKeyboard Get();
+
+ /**
+ * Queries whether a physical keyboard is attached or not.
+ * @return true if a physical keyboard is attached, false otherwise.
+ */
+ bool IsAttached() const;
+
+ // Signals
+
+ /**
+ * Emitted when the status of the physical keyboard changes.
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(PhysicalKeyboard keyboard);
+ * @endcode
+ * @pre The PhysicalKeyboard has been initialized.
+ * @return The status changed signal.
+ */
+ Signal& StatusChangedSignal();
+
+ // Not intended for application developers
+
+ /**
+ * Creates a new handle from the implementation.
+ * @param[in] impl A pointer to the object.
+ */
+ explicit DALI_INTERNAL PhysicalKeyboard( Internal::Adaptor::PhysicalKeyboard* impl );
+};
+
+} // namespace Dali
+
+#endif // __DALI_PHYSICAL_KEYBOARD_H__
--- /dev/null
+#ifndef __DALI_PIXMAP_IMAGE_H__
+#define __DALI_PIXMAP_IMAGE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/object/any.h>
+
+namespace Dali DALI_IMPORT_API
+{
+class Adaptor;
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class PixmapImage;
+}
+}
+
+class PixmapImage;
+/**
+ * @brief Pointer to Dali::PixmapImage.
+ */
+typedef IntrusivePtr<PixmapImage> PixmapImagePtr;
+
+/**
+ * @brief Used for displaying native Pixmap images.
+ *
+ * The native pixmap can be created internally or
+ * externally by X11 or ECORE-X11.
+ *
+ */
+class PixmapImage : public NativeImage
+{
+public:
+
+ /**
+ * @brief PixmapImage can use pixmaps created by X11 or ECORE X11.
+ */
+ enum PixmapAPI
+ {
+ X11, ///< X types
+ ECORE_X11, ///< EFL e-core x11 types
+ };
+
+ /**
+ * @brief When creating a pixmap the color depth has to be specified.
+ */
+ enum ColorDepth
+ {
+ COLOR_DEPTH_DEFAULT, ///< Uses the current X screen default depth (recommended)
+ COLOR_DEPTH_8, ///< 8 bits per pixel
+ COLOR_DEPTH_16, ///< 16 bits per pixel
+ COLOR_DEPTH_24, ///< 24 bits per pixel
+ COLOR_DEPTH_32 ///< 32 bits per pixel
+ };
+
+ /**
+ * @brief Create a new PixmapImage.
+ *
+ * Depending on hardware the width and height may have to be a power of two.
+ * @param[in] width The width of the image.
+ * @param[in] height The height of the image.
+ * @param[in] depth color depth of the pixmap
+ * @param[in] adaptor reference to dali adaptor
+ * @return A smart-pointer to a newly allocated image.
+ */
+ static PixmapImagePtr New( unsigned int width, unsigned int height, ColorDepth depth, Adaptor& adaptor );
+
+ /**
+ * @brief Create a new PixmapImage from an existing pixmap.
+ *
+ * @param[in] pixmap must be a X11 pixmap or a Ecore_X_Pixmap
+ * @param[in] adaptor reference to dali adaptor
+ * @return A smart-pointer to a newly allocated image.
+ */
+ static PixmapImagePtr New( Any pixmap, Adaptor& adaptor );
+
+ /**
+ * @brief Retrieve the internal pixmap
+ *
+ * @param api whether to return a pixmap that can be used with X11 or EFL
+ * @return pixmap any object containing a pixmap of the type specified PixmapAPI
+ */
+ Any GetPixmap( PixmapAPI api );
+
+ /**
+ * @brief Retrieve the display used to create the pixmap.
+ *
+ * If the pixmap was created outside of Dali, then this display
+ * is the one Dali uses internally.
+ * @return Any object containing the display
+ */
+ Any GetDisplay();
+
+ /**
+ * @brief Get a copy of the pixels used by PixmapImage.
+ *
+ * This is only supported for 24 bit RGB and 32 bit RGBA internal formats
+ * (COLOR_DEPTH_24 and COLOR_DEPTH_32).
+ * @param[out] pixbuf a vector to store the pixels in
+ * @param[out] width width of image
+ * @param[out] height height of image
+ * @param[out] pixelFormat pixel format used by image
+ * @return True if the pixels were gotten, and false otherwise.
+ */
+ bool GetPixels( std::vector<unsigned char>& pixbuf, unsigned int& width, unsigned int& height, Pixel::Format& pixelFormat ) const;
+
+ /**
+ * @brief Convert the current pixel contents to either a JPEG or PNG format
+ * and write that to the filesytem.
+ *
+ * @param[in] filename Identify the filesytem location at which to write the
+ * encoded image. The extension determines the encoding used.
+ * The two valid encoding are (".jpeg"|".jpg") and ".png".
+ * @return True if the pixels were written, and false otherwise.
+ */
+ bool EncodeToFile(const std::string& filename) const;
+
+private: // native image
+
+ /**
+ * @copydoc Dali::NativeImage::GlExtensionCreate()
+ */
+ virtual bool GlExtensionCreate();
+
+ /**
+ * @copydoc Dali::NativeImage::GlExtensionDestroy()
+ */
+ virtual void GlExtensionDestroy();
+
+ /**
+ * @copydoc Dali::NativeImage::TargetTexture()
+ */
+ virtual unsigned int TargetTexture();
+
+ /**
+ * @copydoc Dali::NativeImage::PrepareTexture()
+ */
+ virtual void PrepareTexture();
+
+ /**
+ * @copydoc Dali::NativeImage::GetWidth()
+ */
+ virtual unsigned int GetWidth() const;
+
+ /**
+ * @copydoc Dali::NativeImage::GetHeight()
+ */
+ virtual unsigned int GetHeight() const;
+
+ /**
+ * @copydoc Dali::NativeImage::GetPixelFormat()
+ */
+ virtual Pixel::Format GetPixelFormat() const;
+
+private:
+
+ /**
+ * @brief Private constructor
+ * @param[in] width The width of the image.
+ * @param[in] height The height of the image.
+ * @param[in] depth color depth of the pixmap
+ * @param[in] adaptor a reference to Dali adaptor
+ * @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
+ */
+ PixmapImage(unsigned int width, unsigned int height, ColorDepth depth, Adaptor& adaptor, Any pixmap);
+
+ /**
+ * @brief A reference counted object may only be deleted by calling Unreference().
+ *
+ * The implementation should destroy the NativeImage resources.
+ */
+ virtual ~PixmapImage();
+
+ /**
+ * @brief Undefined assignment operator.
+ *
+ * This avoids accidental calls to a default assignment operator.
+ * @param[in] rhs A reference to the object to copy.
+ */
+ PixmapImage& operator=(const PixmapImage& rhs);
+
+private:
+
+ Internal::Adaptor::PixmapImage* mImpl; ///< Implementation pointer
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_PIXMAP_IMAGE_H__
--- /dev/null
+#ifndef __DALI_RENDER_SURFACE_H__
+#define __DALI_RENDER_SURFACE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/public-api/math/rect.h>
+#include <dali/public-api/object/any.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+/**
+ * @brief The position and size of the render surface.
+ */
+typedef Dali::Rect<int> PositionSize;
+
+/**
+ * @brief Interface for a render surface onto which Dali draws.
+ *
+ * Dali::Adaptor requires a render surface to draw on to. This is
+ * usually a window in the native windowing system, or some other
+ * mapped pixel buffer.
+ *
+ * Dali::Application will automatically create a render surface using a window.
+ *
+ * The implementation of the factory method below should choose an appropriate
+ * implementation of RenderSurface for the given platform
+ */
+class RenderSurface
+{
+public:
+ /**
+ * @brief enumeration of surface types
+ */
+ enum SurfaceType
+ {
+ NO_SURFACE, ///< not configured
+ PIXMAP, ///< Pixmap
+ WINDOW, ///< Window
+ NATIVE_BUFFER ///< Native Buffer
+ };
+
+ /**
+ * @brief When application uses pixmap surface, it can select rendering mode.
+ *
+ * RENDER_SYNC : application should call RenderSync() after posting the offscreen to onscreen
+ * RENDER_#FPS : the maximum performance will be limited designated number of frame
+ */
+ enum RenderMode
+ {
+ RENDER_DEFAULT = -1,
+ RENDER_SYNC = 0,
+ RENDER_24FPS = 24,
+ RENDER_30FPS = 30,
+ RENDER_60FPS = 60
+ };
+
+ /**
+ * @brief Constructor
+ *
+ * Application or Adaptor needs to create the appropriate concrete RenderSurface type.
+ * @see CreateDefaultSurface
+ */
+ RenderSurface();
+
+ /**
+ * @brief Virtual Destructor.
+ */
+ virtual ~RenderSurface();
+
+ /**
+ * @brief returns the surface type.
+ * @return the surface type
+ */
+ virtual SurfaceType GetType() = 0;
+
+ /**
+ * @brief Returns the window or pixmap surface.
+ * @return surface
+ */
+ virtual Any GetSurface() = 0;
+
+ /**
+ * @brief Returns the display.
+ * @return display
+ */
+ virtual Any GetDisplay() = 0;
+
+ /**
+ * @brief Return the size and position of the surface.
+ * @return The position and size
+ */
+ virtual PositionSize GetPositionSize() const = 0;
+
+ /**
+ * @brief Set frame update rate for pixmap surface type
+ */
+ virtual void SetRenderMode(RenderMode mode) = 0;
+
+ /**
+ * @brief Get current fps for pixmap surface type
+ * @return The render mode
+ */
+ virtual RenderMode GetRenderMode() const = 0;
+
+private:
+
+ /**
+ * @brief Undefined copy constructor. RenderSurface cannot be copied
+ */
+ RenderSurface( const RenderSurface& rhs );
+
+ /**
+ * @brief Undefined assignment operator. RenderSurface cannot be copied
+ */
+ RenderSurface& operator=( const RenderSurface& rhs );
+
+};
+
+/**
+ * @brief Default surface factory function.
+ *
+ * A surface is created with the given type.
+ *
+ * @param [in] type the type of surface to create
+ * @param [in] positionSize the position and size of the surface to create
+ * @param [in] name optional name of surface passed in
+ * @return The render surface
+ */
+RenderSurface* CreateDefaultSurface( RenderSurface::SurfaceType type, PositionSize positionSize, const std::string& name = "" );
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_RENDER_SURFACE_H__
--- /dev/null
+#ifndef __DALI_SOUND_PLAYER_H__
+#define __DALI_SOUND_PLAYER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal-v2.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class SoundPlayer;
+}
+}
+
+/**
+ * @brief Plays sound effects.
+ */
+class SoundPlayer : public BaseHandle
+{
+public:
+
+ typedef SignalV2< void (SoundPlayer&) > SoundPlayFinishedSignalV2; ///< Sound play finished signal
+
+ // Signal Names
+ static const char* const SIGNAL_SOUND_PLAY_FINISHED; ///< name "sound-play-finished"
+
+public:
+
+ /**
+ * @brief Create an uninitialized handle.
+ *
+ * This can be initialized by calling SoundPlayer::Get().
+ */
+ SoundPlayer();
+
+ /**
+ * @brief Create an initialized handle to the SoundPlayer.
+ *
+ * @return A handle to a newly allocated Dali resource.
+ */
+ static SoundPlayer Get();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~SoundPlayer();
+
+ /**
+ * @brief Plays a sound file.
+ *
+ * @pre The SoundPlayer needs to be initialized.
+ * @param[in] fileName Path to the sound file to play.
+ * @return a handle to the currently playing sound file which can be used to stop.
+ */
+ int PlaySound(const std::string fileName);
+
+ /**
+ * @brief Stops the currently playing sound.
+ *
+ * @pre The SoundPlayer needs to be initialized.
+ * @param[in] handle
+ */
+ void Stop(int handle);
+
+ /**
+ * @brief This signal will be emitted after a given sound file is completely played.
+ *
+ * @pre The SoundPlayer needs to be initialized.
+ * @return The signal to connect to.
+ */
+ SoundPlayFinishedSignalV2& SoundPlayFinishedSignal();
+
+public: // Not intended for application developers
+
+ /**
+ * @brief This constructor is used by SoundPlayer::Get().
+ *
+ * @param[in] soundPlayer A pointer to the sound player.
+ */
+ SoundPlayer( Internal::Adaptor::SoundPlayer* soundPlayer );
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_SOUND_PLAYER_H__
--- /dev/null
+#ifndef __DALI_STYLE_CHANGE_H__
+#define __DALI_STYLE_CHANGE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+namespace Dali DALI_IMPORT_API
+{
+
+/**
+ * @brief Used to describe what style information has changed.
+ *
+ * This structure is used when any style changes occur and contains information about what exactly
+ * has changed.
+ */
+struct StyleChange
+{
+ // Data
+
+ bool defaultFontChange:1; ///< Denotes that the default font has changed.
+ bool defaultFontSizeChange:1; ///< Denotes that the default font size has changed.
+ bool themeChange:1; ///< Denotes that the theme has changed.
+ std::string themeFilePath; ///< Contains the path to the new theme file.
+
+ // Construction
+
+ /**
+ * @brief Default Constructor.
+ */
+ StyleChange()
+ : defaultFontChange(false),
+ defaultFontSizeChange(false),
+ themeChange(false)
+ {
+ }
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_STYLE_CHANGE_H__
--- /dev/null
+#ifndef __DALI_STYLE_MONITOR_H__
+#define __DALI_STYLE_MONITOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+#include <string>
+
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal-v2.h>
+
+// INTERNAL INCLUDES
+#include "style-change.h"
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class StyleMonitor;
+}
+}
+
+/**
+ * @brief Monitors the platform for style changes.
+ *
+ * This is a handle to the adaptor's style monitor which holds the platform's style information.
+ * It provides a signal when any aspect of the default style changes on the device.
+ * @see Adaptor::GetStyleMonitor
+ */
+class StyleMonitor : public BaseHandle
+{
+public: // Typedefs
+
+ typedef SignalV2< void (StyleMonitor, StyleChange) > StyleChangeSignalV2; ///< StyleChange Signal type
+
+public: // Creation & Destruction
+
+ /**
+ * @brief Create an uninitialized StyleMonitor handle.
+ *
+ * Tthis can be set by retrieving the style monitor from the Adaptor
+ * or the Application classes. Calling member functions when
+ * uninitialized is not allowed.
+ */
+ StyleMonitor();
+
+ /**
+ * @brief Creates a copy of the handle.
+ *
+ * The copy will point to the same implementation as the original.
+ * @param[in] monitor The Style Monitor to copy from.
+ */
+ StyleMonitor(const StyleMonitor& monitor);
+
+ /**
+ * @brief Retrieve the initialized instance of the StyleMonitor.
+ * @return Handle to StyleMonitor.
+ */
+ static StyleMonitor Get();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~StyleMonitor();
+
+ /**
+ * @brief Downcast an Object handle to StyleMonitor handle.
+ *
+ * If handle points to a StyleMonitor object the downcast produces a
+ * valid handle. If not the returned handle is left uninitialized.
+ *
+ * @param[in] handle to An object @return handle to a Timer object
+ * or an uninitialized handle
+ */
+ static StyleMonitor DownCast( BaseHandle handle );
+
+ /**
+ * @copydoc Dali::BaseHandle::operator=
+ */
+ using BaseHandle::operator=;
+
+public: // Style Information
+
+ /**
+ * @brief Retrieves the default font family.
+ * @return The default font family.
+ */
+ std::string GetDefaultFontFamily() const;
+
+ /**
+ * @brief Retrieves the default font size
+ * @return The default font size.
+ */
+ float GetDefaultFontSize() const;
+
+ /**
+ * @brief Retrieves the user defined Theme.
+ * @return The user defined Theme.
+ */
+ const std::string& GetTheme() const;
+
+ /**
+ * @brief Sets an user defined Theme.
+ * @param[in] themeFilePath Path of the user defined theme
+ */
+ void SetTheme(const std::string& themeFilePath);
+
+public: // Signals
+
+ /**
+ * @brief This signal is emitted whenever the style changes on the device.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(StyleMonitor styleMonitor, StyleChange change);
+ * @endcode
+ * @return The signal to connect to.
+ */
+ StyleChangeSignalV2& StyleChangeSignal();
+
+public: // Operators
+
+ /**
+ * @brief Assignment operator.
+ *
+ * The handle points to the same implementation as the one being copied from.
+ * @param[in] monitor The Style Monitor to copy from.
+ * @return reference to this object
+ */
+ StyleMonitor& operator=(const StyleMonitor& monitor);
+
+
+public: // Not intended for application developers
+ /**
+ * @brief This constructor is used internally to create a handle from an object pointer.
+ * @param [in] styleMonitor A pointer the internal style monitor.
+ */
+ explicit DALI_INTERNAL StyleMonitor(Internal::Adaptor::StyleMonitor* styleMonitor);
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_STYLE_MONITOR_H__
--- /dev/null
+#ifndef __DALI_TILT_SENSOR_H__
+#define __DALI_TILT_SENSOR_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal-v2.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class TiltSensor;
+}
+}
+
+/**
+ * TiltSensor provides pitch & roll values when the device is tilted.
+ * The basic usage is shown below:
+ *
+ * @code
+ *
+ * void Example()
+ * {
+ * TiltSensor sensor = TiltSensor::Get();
+ *
+ * // Try to enable the sensor
+ * if ( sensor.Enable() )
+ * {
+ * // Query the current values
+ * std::cout << "Roll = " << sensor.GetRoll() << ", Pitch = " << sensor.GetPitch() << std::endl;
+ *
+ * // Get notifications when the device is tilted
+ * sensor.SignalTilted().Connect( &OnTilted );
+ * }
+ * }
+ *
+ * void OnTilted()
+ * {
+ * // Query the new values
+ * std::cout << "Roll = " << sensor.GetRoll() << ", Pitch = " << sensor.GetPitch() << std::endl;
+ * }
+ *
+ * @endcode
+ *
+ * While the tilt sensor is enabled, it will periodically poll for the latest pitch & roll values.
+ * For performance & power-saving, applications should disable this polling when no longer needed:
+ *
+ * @code
+ *
+ * void EndExample()
+ * {
+ * // Disable the sensor when no longer needed
+ * TiltSensor::Get().Disable();
+ * }
+ *
+ * @endcode
+ */
+class TiltSensor : public BaseHandle
+{
+public:
+
+ typedef SignalV2< void (const TiltSensor&) > TiltedSignalV2;
+
+ // Signal Names
+ static const char* const SIGNAL_TILTED;
+
+ static const float DEFAULT_UPDATE_FREQUENCY; // 60 hertz
+
+ /**
+ * Create an uninitialized handle.
+ * This can be initialized by calling TiltSensor::Get().
+ */
+ TiltSensor();
+
+ /**
+ * Create an initialized handle to the TiltSensor.
+ * @return A handle to a newly allocated Dali resource.
+ */
+ static TiltSensor Get();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~TiltSensor();
+
+ /**
+ * Attempt to enable the tilt-sensor. This will fail if the underlying sensor hardware is powered-down,
+ * typically this occurs when the device is set to "sleep" mode.
+ * @return True if the tilt-sensor is enabled.
+ */
+ bool Enable();
+
+ /**
+ * Disable the tilt-sensor.
+ */
+ void Disable();
+
+ /**
+ * Query whether the tilt-sensor is disabled.
+ * The sensor may be disabled automatically; typically this occurs when the device is set to "sleep" mode.
+ * @return True if the tilt-sensor is enabled.
+ */
+ bool IsEnabled() const;
+
+ /**
+ * Query the roll value. This is in the range -1 to 1.
+ * When the device is lying face-up on a flat surface, this method will return a value close to zero.
+ * A value close to 1 indicates that the right-side of the device is pointing upwards.
+ * A value close to -1 indicates that the right-side of the device is pointing downwards.
+ * @pre The tilt-sensor is enabled.
+ * @return The roll value.
+ */
+ float GetRoll() const;
+
+ /**
+ * Query the pitch value. This is in the range -1 to 1.
+ * When the device is lying face-up on a flat surface, this method will return a value close to zero.
+ * A value close to 1 indicates that the top of the device is pointing upwards.
+ * A value close to -1 indicates that the top of the device is pointing downwards.
+ * @pre The tilt-sensor is enabled.
+ * @return The pitch value.
+ */
+ float GetPitch() const;
+
+ /**
+ * Retrieve the rotation of the device.
+ * When the device is lying face-up on a flat surface, the rotation angle will be approximately zero.
+ * The roll & pitch of the device is considered to be a rotation around the Y and X axes respectively.
+ * @pre The tilt-sensor is enabled.
+ * @return The rotation in quaternion format.
+ */
+ Quaternion GetRotation() const;
+
+ /**
+ * This signal will be emitted when the device is tilted, if the tilt-sensor is enabled.
+ * The frequency of the signals can be controlled using SetUpdateFrequency().
+ * @return The signal to connect to.
+ */
+ TiltedSignalV2& TiltedSignal();
+
+ /**
+ * Set the sensor update frequency.
+ * The default is TiltSensor::DEFAULT_UPDATE_FREQUENCY.
+ * @param[in] frequencyHertz The frequency in hertz.
+ */
+ void SetUpdateFrequency( float frequencyHertz );
+
+ /**
+ * Query the sensor update frequency.
+ * @return The frequency in hertz.
+ */
+ float GetUpdateFrequency() const;
+
+ /**
+ * Set the threshold value for rotation in Radians, above which TiltedSignal should be emitted.
+ * The default is 0.0f in Radians (i.e) it will be emitted always at the frequency set.
+ * Example tiltSensor.SetRotationThreshold( Radian(Degree(10) ) // A rotation threshold of 10 degrees
+ * @param[in] rotationThreshold The threshold value for rotation.
+ */
+ void SetRotationThreshold( Radian rotationThreshold );
+
+ /**
+ * Query the rotation threshold above which TiltedSignal will be emitted.
+ * @return The rotation degree threshold in Radians.
+ */
+ Radian GetRotationThreshold() const;
+
+public: // Not intended for application developers
+
+ /**
+ * This constructor is used by TiltSensor::Get().
+ * @param[in] sensor A pointer to the tilt sensor.
+ */
+ TiltSensor( Internal::Adaptor::TiltSensor* sensor );
+};
+
+} // namespace Dali
+
+#endif // __DALI_TILT_SENSOR_H__
--- /dev/null
+#ifndef __DALI_TIMER_H__
+#define __DALI_TIMER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/dali-signal-v2.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class Timer;
+}
+}
+
+/**
+ * @brief Mechanism to issue simple periodic or one-shot events.
+ *
+ * Timer is provided for application developers to be able to issue
+ * simple periodic or one-shot events. Please note that timer
+ * callback functions should return as soon as possible, because they
+ * block the next SignalTick. Please note that timer signals are not
+ * in sync with Dali's render timer.
+ *
+ * This class is a handle class so it can be stack allocated and used
+ * as a member.
+ */
+class Timer : public BaseHandle
+{
+public: // Signal typedefs
+
+ typedef SignalV2< bool () > TimerSignalV2; ///< Timer finished signal callback type
+
+public: // API
+
+ /**
+ * @brief Constructor, creates an uninitialized timer.
+ *
+ * Call New to fully construct a timer.
+ */
+ Timer();
+
+ /**
+ * @brief Create an tick Timer that emits periodic signal.
+ *
+ * @param[in] milliSec Interval in milliseconds.
+ * @return a new timer
+ */
+ static Timer New( unsigned int milliSec );
+
+ /**
+ * @brief Copy constructor.
+ *
+ * @param[in] timer The handle to copy. The copied handle will point at the same implementation
+ */
+ Timer( const Timer& timer );
+
+ /**
+ * @brief Assignment operator.
+ *
+ * @param[in] timer The handle to copy. This handle will point at the same implementation
+ * as the copied handle.
+ * @return Reference to this timer handle
+ */
+ Timer& operator=( const Timer& timer );
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~Timer();
+
+ /**
+ * @brief Downcast an Object handle to Timer handle.
+ *
+ * If handle points to a Timer object the downcast produces a valid
+ * handle. If not the returned handle is left uninitialized.
+ *
+ * @param[in] handle to An object
+ * @return handle to a Timer object or an uninitialized handle
+ */
+ static Timer DownCast( BaseHandle handle );
+
+ /**
+ * @copydoc Dali::BaseHandle::operator=
+ */
+ using BaseHandle::operator=;
+
+ /**
+ * @brief Start timer.
+ *
+ * In case a Timer is already running it's time is reset and timer is restarted.
+ */
+ void Start();
+
+ /**
+ * @brief Stop timer.
+ */
+ void Stop();
+
+ /**
+ * @brief Sets a new interval on the timer and starts the timer.
+ *
+ * Cancels the previous timer.
+ * @param milliSec Interval in milliseconds.
+ */
+ void SetInterval( unsigned int milliSec );
+
+ /**
+ * @brief Get the interval of timer.
+ * @returns Interval in milliseconds.
+ */
+ unsigned int GetInterval() const;
+
+ /**
+ * @brief Tells whether timer is running.
+ * @return Whether Timer is started or not.
+ */
+ bool IsRunning() const;
+
+public: // Signals
+
+ /**
+ * @brief Signal emitted after specified time interval.
+ *
+ * The return of the callback decides whether signal emission stops or continues.
+ * If the callback function returns false emission will stop, if true it will continue
+ * This return value is ignored for one-shot events, which will always stop after the first execution.
+ * @returns The signal to Connect() with.
+ */
+ TimerSignalV2& TickSignal();
+
+public: // Not intended for application developers
+ explicit DALI_INTERNAL Timer(Internal::Adaptor::Timer* timer);
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_TIMER_H__
--- /dev/null
+#ifndef __DALI_TTS_PLAYER_H__
+#define __DALI_TTS_PLAYER_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-handle.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class TtsPlayer;
+}
+}
+
+/**
+ * @brief The Text-to-speech Player.
+ */
+class TtsPlayer : public BaseHandle
+{
+public: // ENUMs
+
+ /**
+ * @brief Enumeration of TTS mode.
+ */
+ enum Mode
+ {
+ DEFAULT = 0, ///< Default mode for normal application
+ NOTIFICATION, ///< Notification mode
+ SCREEN_READER, ///< Screen reader mode
+ MODE_NUM
+ };
+
+public: // API
+
+ /**
+ * @brief Create an uninitialized handle.
+ *
+ * This can be initialized by calling TtsPlayer::Get().
+ */
+ TtsPlayer();
+
+ /**
+ * @brief Gets the singleton of the TtsPlayer for each mode.
+ *
+ * Internally, each tts player handles (singleton instance) are managed for each mode.
+ * @param mode the mode of tts-player
+ * @return A handle of the Ttsplayer for given mode.
+ */
+ static TtsPlayer Get(Dali::TtsPlayer::Mode mode = Dali::TtsPlayer::DEFAULT);
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~TtsPlayer();
+
+ /**
+ * @brief Start playing the audio data synthesized from the specified text.
+ *
+ * @pre The TtsPlayer needs to be initialized.
+ * @param[in] text to play.
+ */
+ void Play(const std::string& text);
+
+ /**
+ * @brief Stops playing the utterance.
+ * @pre The TtsPlayer needs to be initialized.
+ */
+ void Stop();
+
+ /**
+ * @brief Pauses the currently playing utterance.
+ * @pre The TtsPlayer needs to be initialized.
+ */
+ void Pause();
+
+ /**
+ * @brief Resumes the previously paused utterance.
+ * @pre The TtsPlayer needs to be initialized.
+ */
+ void Resume();
+
+public: // Not intended for application developers
+
+ /**
+ * @brief This constructor is used by TtsPlayer::Get().
+ * @param[in] ttsPlayer A pointer to the TTS player.
+ */
+ TtsPlayer( Internal::Adaptor::TtsPlayer* ttsPlayer );
+};
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_TTS_PLAYER_H__
--- /dev/null
+#ifndef __DALI_VIRTUAL_KEYBOARD_H__
+#define __DALI_VIRTUAL_KEYBOARD_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/math/rect.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+/**
+ * @brief This namespace is provided for application developers to be able to show and hide the on-screen keyboard.
+ *
+ * Key events are sent to the actor in focus. Focus is set through the actor Public API.
+ */
+namespace VirtualKeyboard
+{
+
+// Types
+
+typedef SignalV2< void () > VoidSignalV2;
+typedef SignalV2< void (bool) > StatusSignalV2;
+
+// Enumerations
+
+/**
+ * @brief The direction of text.
+ */
+enum TextDirection
+{
+ LeftToRight,
+ RightToLeft,
+};
+
+/**
+ * @brief The meaning of the return key.
+ */
+enum ReturnKeyType
+{
+ DEFAULT,
+ DONE,
+ GO,
+ JOIN,
+ LOGIN,
+ NEXT,
+ SEARCH,
+ SEND,
+ SIGNIN
+};
+
+// Functions
+/**
+ * @brief Show the virtual keyboard.
+ */
+void Show();
+
+/**
+ * @brief Hide the virtual keyboard.
+ */
+void Hide();
+
+/**
+ * @brief Returns whether the virtual keyboard is visible or not.
+ * @return true if visible, false otherwise.
+ */
+bool IsVisible();
+
+/**
+ * @brief Set the specific return key into the virtual keyboard.
+ * @param[in] type the kind of return key types.
+ */
+void SetReturnKeyType( ReturnKeyType type );
+
+/**
+ * @brief Retrieve the current return key type.
+ * @return the type of retun key.
+ */
+ReturnKeyType GetReturnKeyType();
+
+/**
+ * @brief Enable/disable prediction (predictive text).
+ *
+ * By default prediction text is enabled.
+ * @param[in] enable true or false to enable or disable
+ * Prediction can not be changed while the keyboard is visible. It must be set in advance of showing keyboard.
+ */
+void EnablePrediction(const bool enable);
+
+/**
+ * @brief Returns whether prediction is enabled in the virtual keyboard
+ * @return true if predictive text enabled, false otherwise.
+ */
+bool IsPredictionEnabled();
+
+/**
+ * @brief Provides size and position of keyboard.
+ *
+ * Position is relative to whether keyboard is visible or not.
+ * If keyboard is not visible then position will be off the screen.
+ * If keyboard is not being shown when this method is called the keyboard is partially setup (IMFContext) to get
+ * the values then taken down. So ideally GetSizeAndPosition() should be called after Show().
+ * @return rect which is keyboard panel x, y, width, height
+ */
+Dali::Rect<int> GetSizeAndPosition();
+
+/**
+ * @brief Rotates the keyboard orientation to the given angle.
+ *
+ * A value of 0 indicates the portrait orientation.
+ * Other valid values are 90, 180, 270.
+ * @param angle the angle is in degrees.
+ */
+void RotateTo(int angle);
+
+/**
+ * @brief Returns text direction of the keyboard's current input language.
+ * @return The direction of the text.
+ */
+TextDirection GetTextDirection();
+
+/**
+ * @brief Connect to this signal to be notified when the virtual keyboard is shown or hidden.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(bool keyboardShown);
+ * @endcode
+ * If the parameter keyboardShown is true, then the keyboard has just shown, if it is false, then it
+ * has just been hidden.
+ * @return The signal to connect to.
+ */
+StatusSignalV2& StatusChangedSignal();
+
+/**
+ * @brief Connect to this signal to be notified when the virtual keyboard is resized.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName();
+ * @endcode
+ * User can get changed size by using GetSizeAndPosition() in the callback
+ * @return The signal to connect to.
+ */
+VoidSignalV2& ResizedSignal();
+
+/**
+ * @brief Connect to this signal to be notified when the virtual keyboard's language is changed.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName();
+ * @endcode
+ * User can get the text direction of the language by calling GetTextDirection() in the callback.
+ * @return The signal to connect to.
+ */
+VoidSignalV2& LanguageChangedSignal();
+
+} // namespace VirtualKeyboard
+
+} // namespace Dali
+
+/**
+ * @}
+ */
+#endif // __DALI_VIRTUAL_KEYBOARD_H__
--- /dev/null
+#ifndef __DALI_WINDOW_H__
+#define __DALI_WINDOW_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @addtogroup CAPI_DALI_ADAPTOR_MODULE
+ * @{
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/public-api/math/rect.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/object/base-handle.h>
+
+namespace Dali DALI_IMPORT_API
+{
+typedef Dali::Rect<int> PositionSize;
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class Window;
+}
+}
+
+class DragAndDropDetector;
+class Orientation;
+
+/**
+ * @brief The window class is used internally for drawing.
+ *
+ * It has an orientation
+ * and indicator properties.
+ */
+class Window : public BaseHandle
+{
+public:
+
+ // Enumerations
+
+ /**
+ * @brief Orientation of the window.
+ */
+ enum WindowOrientation
+ {
+ PORTRAIT = 0,
+ LANDSCAPE = 90,
+ PORTRAIT_INVERSE = 180,
+ LANDSCAPE_INVERSE = 270
+ };
+
+ /**
+ * @brief Opacity of the indicator.
+ */
+ enum IndicatorBgOpacity
+ {
+ OPAQUE = 100, // Fully opaque indicator Bg
+ TRANSLUCENT = 50, // Semi translucent indicator Bg
+ TRANSPARENT = 0 // Fully transparent indicator Bg
+ };
+
+ /**
+ * @brief Visible mode of the indicator.
+ */
+ enum IndicatorVisibleMode
+ {
+ INVISIBLE = 0, // hide indicator
+ VISIBLE = 1, // show indicator
+ AUTO = 2 // hide in default, will show when necessary
+ };
+
+ /**
+ * @brief Style of the indicator.
+ */
+ enum IndicatorStyle
+ {
+ FIXED_COLOR = 0, // fixed color style
+ CHANGEABLE_COLOR // changeable color style
+ };
+
+ // Methods
+
+ /**
+ * @brief Create an initialized handle to a new Window.
+ * @param[in] windowPosition The position and size of the window
+ * @param[in] name The window title
+ * @param[in] isTransparent Whether window is transparent
+ * @return a new window
+ */
+ static Window New(PositionSize windowPosition, std::string name, bool isTransparent = false);
+
+ /**
+ * @brief Create an uninitalized handle.
+ *
+ * This can be initialized using Dali::Application::GetWindow() or
+ * Dali::Window::New()
+ */
+ Window();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~Window();
+
+ /**
+ * @copydoc Dali::BaseHandle::operator=
+ */
+ using BaseHandle::operator=;
+
+ /**
+ * @brief This sets the style of indicator
+ * @param[in] style style type of the indicator
+ *
+ * @note This should be called before ShowIndicator()
+ */
+ void SetIndicatorStyle( IndicatorStyle style );
+
+ /**
+ * @brief This sets whether the indicator bar should be shown or not.
+ * @param[in] show - true if the indicator bar should be shown
+ * @deprecated use "void ShowIndicator( IndicatorVisibleMode visibleMode )"
+ */
+ void ShowIndicator( bool show );
+
+ /**
+ * @brief This sets whether the indicator bar should be shown or not.
+ * @param[in] visibleMode visible mode for indicator bar, VISIBLE in default
+ */
+ void ShowIndicator( IndicatorVisibleMode visibleMode );
+
+ /**
+ * @brief This sets the opacity mode of indicator bar.
+ * @param[in] opacity - The opacity mode
+ */
+ void SetIndicatorBgOpacity( IndicatorBgOpacity opacity );
+
+ /**
+ * @brief This sets the orientation of indicator bar.
+ *
+ * It does not implicitly show the indicator if it is currently
+ * hidden.
+ * @param[in] orientation The orientation
+ */
+ void RotateIndicator(WindowOrientation orientation);
+
+ /**
+ * @brief Set the window name and class string.
+ * @param[in] name The name of the window
+ * @param[in] klass The class of the window
+ */
+ void SetClass(std::string name, std::string klass);
+
+ /**
+ * @brief Raise window to top of window stack.
+ */
+ void Raise();
+
+ /**
+ * @brief Lower window to bottom of window stack.
+ */
+ void Lower();
+
+ /**
+ * @brief Activate window to top of window stack even it is iconified.
+ */
+ void Activate();
+
+ /**
+ * @brief Get the orientation class ( to allow signal connection ).
+ */
+ Orientation GetOrientation();
+
+ /**
+ * @brief Add an orientation to the list of available orientations.
+ */
+ void AddAvailableOrientation( WindowOrientation orientation );
+
+ /**
+ * @brief Remove an orientation from the list of available orientations.
+ */
+ void RemoveAvailableOrientation( WindowOrientation orientation );
+
+ /**
+ * @brief Set the orientations that this window can rotate to.
+ *
+ * By default, the window does not change orientation.
+ * @param[in] orientations The list of orientations
+ */
+ void SetAvailableOrientations( const std::vector<WindowOrientation>& orientations );
+
+ /**
+ * @brief Get the list of orientations this window can rotate to.
+ * @return the list of orientations
+ */
+ const std::vector<WindowOrientation>& GetAvailableOrientations();
+
+ /**
+ * @brief Set a preferred orientation.
+ * @pre orientation is in the list of available orientations
+ * @param[in] orientation The preferred orientation
+ */
+ void SetPreferredOrientation( WindowOrientation orientation );
+
+ /**
+ * @brief Get the preferred orientation.
+ * @return The preferred orientation if previously set, or none.
+ */
+ WindowOrientation GetPreferredOrientation();
+
+ /**
+ * @brief Returns the Drag & drop detector which can be used to receive drag & drop events.
+ * @return A handle to the DragAndDropDetector.
+ */
+ DragAndDropDetector GetDragAndDropDetector() const;
+
+public: // Not intended for application developers
+ /**
+ * @brief This constructor is used by Dali::Application::GetWindow().
+ * @param[in] window A pointer to the window.
+ */
+ explicit Window( Internal::Adaptor::Window* window );
+};
+
+} // namespace Dali
+
+
+/**
+ * @}
+ */
+#endif // __DALI_WINDOW_H__
--- /dev/null
+#!/bin/bash
+# Log resource analyser tool for Dali
+# Monitors resource usage of last run Dali app
+# Shows memory uploaded to GPU or normal RAM
+# Texture atlas usage usually reflects used Font atlases
+
+set -u
+
+#global variables
+TERM_W=0 # latest width of terminal window
+TERM_H=0 # latest height of terminal window
+SEPARATOR_H=5 # 5 lines in info bar
+CURPAGE=0 # current page number
+MAXFILENO=0 # maximum lines to display from resourcelist
+MAXP=0 # number of pages
+
+DLOGTEMPFILE=/tmp/dalidlog.txt
+DLOGUTIL=/usr/bin/dlogutil
+USING_DLOG=
+INPUTFILE=""
+
+
+
+#possible states
+# ID| Desc | Color | Tags
+#---+----------------------------------+-----------+-------
+# 0.| loaded in CPU memory | [CPU] | [LOAD]
+# 1.| present in both memories | [CPUGPU] | [LOAD] [UPLOAD]
+# 2.| GPU memory only, buffer discarded| [GPU] | [UPLOAD] [DELBUF]
+# 3.| loaded but discarded later on | [DISC] | [LOAD] [DELBUF] or [DELBUF] [DELTEXTURE]
+
+#colors for marking resource state
+COLOR_CPU=5
+COLOR_CPUGPU=1
+COLOR_GPU=2
+COLOR_DISC=6
+
+declare -a COLORS=( $COLOR_CPU $COLOR_CPUGPU $COLOR_GPU $COLOR_DISC )
+
+declare -a FILENAMES_G=( )
+declare -a BITMAPS_G=( )
+declare -a TEXTURES_G=( )
+declare -a STATES_G=( )
+declare -a SIZES_G=( )
+declare -a SIZE_DETAILS_G=( )
+
+ATLASMEM=0
+ATLAS_NO=0
+
+CPUMEM=0
+GPUMEM=0
+
+#process ID of last running Dali app
+PID_G=0
+
+#distinguish texture atlases from framebuffer textures
+BITMAP_ID_ATLAS=0
+BITMAP_ID_FB_TEXTURE="-"
+
+###################################string formatting, command line and error handling
+function error
+{
+ echo "Error: $1"
+ cleanup
+ exit 1
+}
+
+function usage
+{
+ echo "usage: ./dalireslog.sh [FILE]"
+ echo "if FILE isn't specified script will try to use dlogutil"
+}
+
+function getTermSize
+{
+ TERM_W=$(tput cols)
+ TERM_H=$(tput lines)
+
+ let MAXFILENO=$(($TERM_H-$SEPARATOR_H-2)) #leave space for keyboard shortcuts and separator itself
+ let MAXP=${#FILENAMES_G[@]}/$MAXFILENO
+
+ # don't show empty page if list just fits on screen
+ local rmd=0
+ let rmd=${#FILENAMES_G[@]}%$MAXFILENO
+ if [ $rmd -eq 0 ]
+ then
+ let MAXP-=1;
+ fi
+}
+
+# print string, notifying user if it doesn't fit in one line. takes one parameter
+function printString
+{
+ echo -n ${1:0:$TERM_W}
+ if [[ $TERM_W -lt ${#1} ]]
+ then
+ tput cub 1;
+ tput setab 1; tput smso; echo -n '>'; tput el; tput rmso
+ return 1
+ else
+ tput el
+ return 0
+ fi
+}
+
+# print string, clear until end of line, print newline. takes one parameter
+function printLine
+{
+ printString "$1"
+ local RET=$?
+ printf '\n'
+ return $RET
+}
+
+function parseCmdLine
+{
+ if [[ $# -lt 1 ]]
+ then
+ # try using dlogutil
+ if [[ ! -e "$DLOGUTIL" ]]
+ then
+ echo "dlogutil not installed"
+ usage
+ exit 1
+ fi
+
+ INPUTFILE="$DLOGTEMPFILE"
+ USING_DLOG=true
+ else
+ # check if help is requested
+ if [[ $1 == '-h' || $1 == '--help' ]]
+ then
+ usage
+ exit 0
+ # try reading from file
+ else
+ INPUTFILE=$1
+ if [[ ! -e "$INPUTFILE" ]]
+ then
+ echo cannot read file "$INPUTFILE"
+ usage
+ exit 1
+ fi
+ fi
+ fi
+}
+
+# print filename or basename or "..." depending on terminal size, takes one parameter
+function printPath
+{
+ if [ -z "$1" ]
+ then
+ echo "ERROR in printPath";
+ cleanup; exit 1
+ fi
+
+ FILENAME="$1"
+ FBASENAME=$(basename $FILENAME)
+ if [[ ${#FILENAME} -lt $TERM_W ]]
+ then
+ printLine "$FILENAME"
+ else
+ if [[ ${#FBASENAME} -lt $TERM_W ]]
+ then
+ printLine "$FBASENAME"
+ else
+ printLine ...
+ fi
+ fi
+}
+
+###################################memory query functions
+function getGpuMemUsage
+{
+ GPUMEM=0
+ local i=0
+ for state in ${STATES_G[@]}
+ do
+ if [[ $state == 1 || $state == 2 ]]
+ then
+ let GPUMEM+=${SIZES_G[$i]}
+ fi
+ let i+=1
+ done
+ return $GPUMEM
+}
+
+function getCpuMemUsage
+{
+ CPUMEM=0
+ local i=0
+ for state in ${STATES_G[@]}
+ do
+ if [[ $state == 0 || $state == 1 ]]
+ then
+ let CPUMEM+=${SIZES_G[$i]}
+ fi
+ let i+=1
+ done
+ return $CPUMEM
+}
+
+function getAtlasNumber
+{
+ ATLAS_NO=0
+ local i=0
+ for bitmap in ${BITMAPS_G[@]}
+ do
+ if [[ $bitmap == 0 && ${STATES_G[$i]} == 2 ]]
+ then
+ let ATLAS_NO+=1
+ fi
+ let i+=1
+ done
+ return $ATLAS_NO
+}
+
+function getAtlasMemUsage
+{
+ ATLASMEM=0
+ local i=0
+ for bitmap in ${BITMAPS_G[@]}
+ do
+ if [[ $bitmap == 0 && ${STATES_G[$i]} == 2 ]]
+ then
+ let ATLASMEM+=${SIZES_G[$i]}
+ fi
+ let i+=1
+ done
+ return $ATLASMEM
+}
+
+##################################global arrays manipulation
+#adds record to resource list
+#params: filename, bitmap, texture, state, size, size detail
+function addRecord
+{
+ if [ $# -ne 6 ]
+ then
+ error "addRecord - number of arguments is $#"
+ fi
+ FILENAMES_G+=("$1")
+ BITMAPS_G+=("$2")
+ TEXTURES_G+=("$3")
+ STATES_G+=("$4")
+ SIZES_G+=("$5")
+ SIZE_DETAILS_G+=("$6")
+}
+
+#adds image resource to list
+#params: filename, bitmap, size, size detail
+function fileLoaded
+{
+ if [ $# -ne 4 ]
+ then
+ error "fileLoaded"
+ fi
+ FILENAMES_G+=("$1")
+ BITMAPS_G+=("$2")
+ SIZES_G+=("$3")
+ SIZE_DETAILS_G+=("$4")
+ TEXTURES_G+=(0)
+ STATES_G+=(0)
+}
+
+#params: texture, size, size detail
+function atlasUploaded
+{
+ FILENAMES_G+=("-")
+ BITMAPS_G+=("$BITMAP_ID_ATLAS")
+ TEXTURES_G+=("$1")
+ STATES_G+=(2)
+ SIZES_G+=("$2")
+ SIZE_DETAILS_G+=("$3")
+}
+
+#params: size, size detail
+function frameBufUploaded
+{
+ FILENAMES_G+=("$1")
+ BITMAPS_G+=("$BITMAP_ID_FB_TEXTURE")
+ TEXTURES_G+=("$2")
+ STATES_G+=(2)
+ SIZES_G+=("$3")
+ SIZE_DETAILS_G+=("$4")
+}
+
+
+##################################log parsing functions
+function checkLoaded
+{
+ if [[ "$1" =~ .*DALI.*[LOAD].*file\ (.*)\ to\ Bitmap\ (.*)\ -\ size\ ([[:digit:]]*)\ bytes\ (.*) ]]
+ then
+ local FILENAME="${BASH_REMATCH[1]}"
+ local BITMAP="${BASH_REMATCH[2]}"
+ local SIZE="${BASH_REMATCH[3]}"
+ local SIZE_DETAILS="${BASH_REMATCH[4]}"
+
+ local found=0
+
+ #check if file was loaded before with same size
+ local i=0
+ if [ ${#FILENAMES_G[@]} -ne 0 ]
+ then
+
+ for filenameIter in ${FILENAMES_G[@]}
+ do
+ if [[ "$filenameIter" == "$FILENAME" ]]
+ then
+ if [[ ${SIZES_G[$i]} == "$SIZE" && ${SIZE_DETAILS_G[$i]} == "$SIZE_DETAILS" ]]
+ then
+ found=1
+ case ${STATES_G[$i]} in
+ 0) #CPU
+ BITMAPS_G[$i]="$BITMAP"
+ ;;
+ 1) #CPUGPU
+ BITMAPS_G[$i]="$BITMAP"
+ ;;
+ 2) #GPU
+ STATES_G[$i]=1 #GPU->CPUGPU loaded into memory again
+ BITMAPS_G[$i]="$BITMAP"
+ ;;
+ 3) #DISC
+ #previously discarded, load again
+ STATES_G[$i]=0
+ BITMAPS_G[$i]="$BITMAP"
+ ;;
+ *)
+ error "checkLoaded - unknown state"
+ ;;
+ esac
+ else
+ #filename is same, but its loaded in different size
+ :
+ fi
+ fi
+ let i+=1
+ done
+ fi
+
+ if [ $found -ne 1 ]
+ then
+ fileLoaded "$FILENAME" "$BITMAP" "$SIZE" "$SIZE_DETAILS"
+ fi
+
+ return 0
+ else
+ error "checkLoaded"
+ fi
+}
+
+function checkUploaded
+{
+ if [[ "$1" =~ .*DALI.*[UPLOAD].*Bitmap\ (.*)\ to\ Texture\ (.*)\ -\ size\ ([[:digit:]]*)\ bytes\ (.*) ]]
+ then
+ local BITMAP="${BASH_REMATCH[1]}"
+ local TEXTURE="${BASH_REMATCH[2]}"
+ local SIZE="${BASH_REMATCH[3]}"
+ local SIZE_DETAILS="${BASH_REMATCH[4]}"
+
+ local i=0
+ local lastIdx=-1
+
+ if [[ "$BITMAP" =~ \(nil\) ]]
+ then
+ atlasUploaded $TEXTURE $SIZE "$SIZE_DETAILS"
+ return 0
+ else
+ #not a texture atlas
+ if [ ${#BITMAPS_G[@]} -ne $BITMAP_ID_ATLAS ]
+ then
+ for bitmap in ${BITMAPS_G[@]}
+ do
+ if [ $bitmap == $BITMAP ]
+ then
+ lastIdx=$i
+ fi
+ let i+=1
+ done
+ fi
+ fi
+
+ if [ $lastIdx != -1 ]
+ then
+ #Bitmap found
+ if [[ ${TEXTURES_G[$lastIdx]} == 0 && ${STATES_G[$lastIdx]} == 0 ]]
+ then
+ #File loaded in memory -> upload to GPU
+ TEXTURES_G[$lastIdx]="$TEXTURE"
+ STATES_G[$lastIdx]=1
+ elif [[ ${FILENAMES_G[$lastIdx]} == "-" && ${STATES_G[$lastIdx]} == 1 ]]
+ then
+ #BitmapImage already in memory and GPU mem. -> updated
+ SIZES_G[$lastIdx]=$SIZE
+ SIZE_DETAILS_G[$lastIdx]="$SIZE_DETAILS"
+ else
+ #bitmap uploaded to new texture
+ addRecord ${FILENAMES_G[$lastIdx]} $BITMAP $TEXTURE 1 $SIZE "$SIZE_DETAILS"
+ fi
+ else
+ #bitmapImage - not loaded from file
+ #newly added
+ addRecord "-" $BITMAP $TEXTURE 1 $SIZE "$SIZE_DETAILS"
+ fi
+ return 0
+ elif [[ "$1" =~ .*DALI.*[UPLOAD].*FrameBufferTexture\ (.*)\ GL\ Texture\ (.*)\ -\ size\ ([[:digit:]]*)\ bytes\ (.*) ]]
+ then
+ local FBTEXTURE="${BASH_REMATCH[1]}"
+ local TEXTURE="${BASH_REMATCH[2]}"
+ local SIZE="${BASH_REMATCH[3]}"
+ local SIZE_DETAILS="${BASH_REMATCH[4]}"
+ frameBufUploaded "$FBTEXTURE" "$TEXTURE" "$SIZE" "$SIZE_DETAILS"
+ return 0
+ else
+ echo "$1"
+ error "checkUploaded"
+ fi
+}
+
+function checkDeletedBuf
+{
+ if [[ "$1" =~ .*DALI.*[DELBUF].*Bitmap\ (.*)\ -\ .*size\ (.*) ]]
+ then
+ local BITMAP=${BASH_REMATCH[1]}
+ local i=0
+
+ for bitmap in ${BITMAPS_G[@]}
+ do
+ if [ $bitmap == "$BITMAP" ]
+ then
+ case ${STATES_G[$i]} in
+ 0)
+ STATES_G[$i]=3 #CPU->DISC
+ ;;
+ 1)
+ STATES_G[$i]=2 #CPUGPU->GPU
+ ;;
+ 2)
+ #GPU->?
+ #probably previously freed bitmap buffer but memory is reused since
+ ;;
+ 3)
+ #DISC->?
+ #probably previously freed but memory is reused since
+ ;;
+ *)
+ error "checkDeletedBuf - unkown state"
+ ;;
+ esac
+ fi
+ let i+=1
+ done
+
+ return 0
+ else
+ echo "$1"
+ error "checkDeletedBuf"
+ fi
+}
+
+function checkDeletedTexture
+{
+ if [[ "$1" =~ .*DALI.*[DELTEXTURE].*Texture\ (.*)\ -\ size\ (.*) ]]
+ then
+ local TEXTURE="${BASH_REMATCH[1]}"
+ local i=0
+ local lastIdx=-1
+
+ for texture in ${TEXTURES_G[@]}
+ do
+ if [ $texture == $TEXTURE ]
+ then
+ lastIdx=$i
+ fi
+ let i+=1
+ done
+
+ if [ $lastIdx != -1 ]
+ then
+ case ${STATES_G[$lastIdx]} in
+ 0)
+ #CPU->?
+ echo "$1"
+ error "checkDeletedTexture - state CPU"
+ ;;
+ 1)
+ STATES_G[$lastIdx]=0 #CPUGPU->CPU
+ ;;
+ 2)
+ STATES_G[$lastIdx]=3 #GPU->DISC
+ ;;
+ 3)
+ #DISC->?
+ echo "$1"
+ error "checkDeletedTexture - state DISC"
+ ;;
+ *)
+ error "checkDeletedTexture - unkown state"
+ ;;
+ esac
+ else
+ echo "$1"
+ error "checkDeletedTexture - texture not uploaded"
+ fi
+ return 0
+ else
+ echo "$1"
+ error "checkDeletedTexture"
+ fi
+}
+
+function processLine
+{
+ if [[ "$1" =~ .*DALI.*\ \[(.*)\].* ]]
+ then
+ RESCMD=${BASH_REMATCH[1]}
+ case "$RESCMD" in
+ LOAD)
+ checkLoaded "$1"
+ ;;
+ UPLOAD)
+ checkUploaded "$1"
+ ;;
+ DELBUF)
+ checkDeletedBuf "$1"
+ ;;
+ DELTEXTURE)
+ checkDeletedTexture "$1"
+ ;;
+ INIT)
+ ;;
+ FIN)
+ return 1 #end of last log session
+ ;;
+ *)
+ error "Unkown command $RESCMD"
+ ;;
+ esac
+ fi
+ return 0
+}
+
+function parseFile
+{
+ if [ -z "$1" ]
+ then
+ echo "ERROR in parseFile";
+ cleanup; exit 1
+ fi
+
+ #return if file does not contain dali resource log
+ if ! grep -q -m 1 -E "DALI.*\[INIT\]" $1
+ then
+ return 1
+ fi
+
+ #find last resource log session
+ local LOGBUFFER=$(sed -n 'H; /DALI.*\[INIT\]/h; ${g;p;}' $1)
+
+ while read -r line
+ do
+ #show PID of last process
+ PID_G=$(echo "$line" | sed 's/[^0-9]*\([0-9]*\).*/\1/')
+ if [ ! -z "$PID_G" ]
+ then
+ break
+ fi
+ done <<< "$LOGBUFFER"
+
+ while read -r line
+ do
+ if ! processLine "$line" #stop parsing at the end of last session
+ then
+ break
+ fi
+ done <<< "$LOGBUFFER"
+}
+
+##################################draw and main functions
+function redraw
+{
+ tput cup 0 0 #move cursor to top left
+
+ # print info (4 lines)
+ tput bold
+ printLine "PID: $PID_G"
+ printLine "MEM 3D: $GPUMEM"
+ printLine "MEM Atlas: $ATLASMEM";
+ printLine "MEM CPU: $CPUMEM"
+ printLine "Number of atlases: $ATLAS_NO";
+ tput sgr0
+
+ # separator bar (colored bar with (actual/number of files) count)
+ tput cup $SEPARATOR_H 0
+ local PAGEIND="$(expr $CURPAGE + 1)/$(expr $MAXP + 1)"
+ local FILL_W=0
+ let FILL_W=$TERM_W-${#PAGEIND}
+ tput setab 4; printf $PAGEIND%"$FILL_W"s; printf '\n'; tput sgr0
+
+ # print filenames
+ local count=0
+ local index=0
+ let index=$CURPAGE*$MAXFILENO
+
+ filecount=${#FILENAMES_G[@]}
+
+ tput setaf 252
+
+ while [[ $count -lt $MAXFILENO ]]
+ do
+ if [[ $index -lt $filecount ]]
+ then
+ tput setab ${COLORS[${STATES_G[$index]}]}
+# printPath "${FILENAMES_G[$count]}"
+ printLine "${FILENAMES_G[$index]} ${SIZES_G[$index]} ${SIZE_DETAILS_G[$index]}"
+ else
+ tput sgr0
+ printLine "" #clear remaining lines to fill screen
+ fi
+ let count+=1
+ let index+=1
+ done
+
+ # print keyboard shortcuts
+ tput setab 4; tput bold
+ IFS= printString " | n: next page | p: previous page | ^C: exit | Resource state: "
+ # print color codes
+ if [[ $TERM_W -gt 100 ]]
+ then
+ tput setab ${COLORS[0]}
+ echo -n " CPU "
+ tput setab ${COLORS[1]}
+ echo -n " CPUGPU "
+ tput setab ${COLORS[2]}
+ echo -n " GPU "
+ tput setab ${COLORS[3]}
+ echo -n " DISCARDED "
+ fi
+
+ tput sgr0
+}
+
+function readInput
+{
+ local key
+ read -n1 -t 0.3 key
+
+ case "$key" in
+ 'p')
+ if [[ $CURPAGE -ne 0 ]]
+ then
+ let CURPAGE-=1
+ fi
+ ;;
+ 'n')
+ if [[ $CURPAGE -lt $MAXP ]]
+ then
+ let CURPAGE+=1
+ fi
+ ;;
+ esac
+}
+
+function initVars
+{
+ FILENAMES_G=( )
+ BITMAPS_G=( )
+ TEXTURES_G=( )
+ SIZES_G=( )
+ SIZE_DETAILS_G=( )
+ STATES_G=( )
+}
+
+function cleanup
+{
+ tput cup 9999 0 #go to bottom of screen
+ tput cnorm #show cursor
+ tput sgr0
+ if [ -f "$DLOGTEMPFILE" ]
+ then
+ rm "$DLOGTEMPFILE"
+ fi
+}
+
+function update
+{
+ initVars
+ if [ -n "$USING_DLOG" ]
+ then
+ if [ -f "$DLOGTEMPFILE" ]
+ then
+ rm "$DLOGTEMPFILE"
+ fi
+ "$DLOGUTIL" DALI:I -d -f "$DLOGTEMPFILE" 2>/dev/null
+ fi
+
+ if [ ! -e "$INPUTFILE" ]
+ then
+ return 1
+ fi
+
+ parseFile "$INPUTFILE"
+
+ if [[ $? -gt 0 || ${#STATES_G[@]} -lt 1 ]]
+ then
+ return 1
+ fi
+
+ getCpuMemUsage
+ getGpuMemUsage
+ getAtlasMemUsage
+ getAtlasNumber
+
+ getTermSize
+ readInput
+ redraw
+}
+
+function main
+{
+ parseCmdLine $@
+
+ if [ -z "$INPUTFILE" ]
+ then
+ echo No input file specified;
+ cleanup
+ exit 1
+ fi
+
+ tput civis #hide cursor
+ tput clear #clear screen
+
+ echo "waiting for log..."
+
+ while [ 1 ]
+ do
+ update
+# sleep 0.3 # we are now reading input for 0.3
+ done
+
+ cleanup
+}
+
+trap "cleanup; exit 0" SIGINT SIGTERM #reset terminal when ^C is pressed
+# trap "getTermSize" SIGWINCH #handle window resize
+
+main $@
--- /dev/null
+Resource log analyzer tool for dali applications
+
+USAGE:
+./dalireslog.sh [FILE]
+if FILE isn't specified script will try to use dlogutil
+
+Example:
+
+sh-4.1$ ./dalireslog.sh
+on a separate terminal:
+sh-4.1$ DALI_ENABLE_LOG=RESOURCE_LOG /opt/apps/com.samsung.dali-demo/bin/album.example
+
+Displayed information:
+3D - amount of GPU memory used by application
+MEM Atlas - amount of GPU memory used by texture atlases. Usually this means font atlases.
+Number of atlases - how many texture atlases are present in memory
+
+A list of files is displayed in the main view, with different color codes representing different states.
+
+CPU - resource is in memory, but hasn't been uploaded to a GL texture
+GPU - resource has been uploaded to a GL texture, bitmap buffer discarded
+CPUGPU - resource has been uploaded to a GL texture, but still present in CPU memory as well
+DISCARDED - resource has been discarded, memory freed up
--- /dev/null
+#!/usr/bin/env ruby
+# To use type parse.rb in the same folder as gl-abstraction.h
+# and pipe the output to a file
+#
+# Assemble the gl function call
+#
+# turns this: GLBoolean BlendEquation(GLEnum mode);
+#
+# into an inline function like this:
+#
+# GLBoolean BlendEquation(GLEnum mode)
+# {
+# return glBlendEquation(mode);
+# }
+
+f = File.new("x11-gles.h")
+#scan each line in the file
+f.each do |x|
+
+ # x is original line, y is the new gl function call
+ y = String.new(x)
+
+ y.lstrip! # strip leading white spaces
+ returns = y.index("void"); # see if the function returns void
+ y.gsub!'void',' ' # delete the return types ...
+ y.gsub!(/GL[a-z]*/, '') # remove GL types such as GLenum
+ y.gsub!('const','') # remove const, *
+ y.gsub!('char','') # remove char
+ y.gsub!('*','') # remove pointer *
+ y.gsub!(/\s+/,"") # remove all spaces
+ y.insert(0,' gl') # add gl to function name
+
+ if (returns != 0) # insert a return if the function returns
+ y.lstrip!
+ y.insert(0,' return ')
+ end
+
+ # print the function out
+ y << "\n"
+ x.lstrip!
+ x.gsub!(';','')
+ print x
+ print "{\n"
+ print y
+ print "}\n\n"
+end
+
+
+
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "abort-handler.h"
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-AbortHandler* AbortHandler::gInstance(NULL);
-
-AbortHandler::AbortHandler(boost::function<void(void)> callback)
-: mSignalMask( 0 ),
- mCallback( callback )
-{
- DALI_ASSERT_ALWAYS( gInstance == NULL && "Only one instance of abort handler allowed" );
- gInstance = this;
-
- memset( mSignalOldHandlers, 0, sizeof(SignalHandlerFuncPtr) * (_NSIG-1));
-}
-
-AbortHandler::~AbortHandler()
-{
- int signum;
- for ( signum = 1; signum < _NSIG; signum++ )
- {
- if ( mSignalMask & (1 << (signum-1) ) )
- {
- // set signals back to default handling
- signal( signum, mSignalOldHandlers[signum-1] );
- }
- }
- gInstance = NULL;
-}
-
-bool AbortHandler::AbortOnSignal( int signum )
-{
- bool status = false;
-
- if ( signum < _NSIG )
- {
- SignalHandlerFuncPtr signalHandlerPrevious = signal( signum, &AbortHandler::SignalHandler );
-
- if ( SIG_ERR != signalHandlerPrevious )
- {
- mSignalOldHandlers[signum-1] = signalHandlerPrevious;
- mSignalMask |= ( 1 << (signum-1) );
- status = true;
- }
- }
- return status;
-}
-
-void AbortHandler::SignalHandler( int signum )
-{
- if( gInstance )
- {
- if( gInstance->mCallback )
- {
- gInstance->mCallback();
- }
- }
-}
-
-} // Adaptor
-} // Internal
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H__
-#define __DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <signal.h>
-#include "public-api/adaptor-framework/application.h"
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-/**
- * Class to listen to system signals and trigger an abort callback
- * when they occur.
- *
- * This class maintains a process wide singleton, as the signal(2) system
- * call is process specific, not thread specific.
- *
- * Currently, this precludes having multiple DALi instances in the same process.
- */
-class AbortHandler
-{
-public:
- /**
- * Constructor
- * @param[in] callback The function to call when abort signals occur
- */
- AbortHandler(boost::function<void(void)> callback);
-
- /**
- * Destructor
- */
- ~AbortHandler();
-
- /**
- * Add a signal you want to be handled by this abort handler.
- * @param[in] signum The signal number (from signum.h)
- * @return true if the signal handler was installed ok
- */
- bool AbortOnSignal( int signum );
-
-private:
- /**
- * Signal handler - Called when signal is received.
- * Stops the application.
- */
- static void SignalHandler( int signum );
-
- /**
- * Default constructor - undefined
- */
- AbortHandler();
-
- /**
- * Copy constructor - undefined
- */
- AbortHandler(const AbortHandler& rhs);
-
- /**
- * Assignment operator - undefined
- */
- AbortHandler& operator=(const AbortHandler& rhs);
-
-private:
- typedef void (*SignalHandlerFuncPtr )( int );
-
- // _NSIG comes from the signal.h linux system header, defining the number of signals.
- SignalHandlerFuncPtr mSignalOldHandlers[_NSIG-1];
- unsigned long long mSignalMask;
-
- boost::function<void(void)> mCallback;
-
- static AbortHandler* gInstance;
-};
-
-} // Namespace Adaptor
-} // Namespace Internal
-} // Namespace Dali
-
-#endif // __DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H__
+++ /dev/null
-# Application
-
-tizen_application_internal_src_files = \
- $(tizen_application_internal_src_dir)/application-impl.cpp \
- $(tizen_application_internal_src_dir)/framework.cpp \
- $(tizen_application_internal_src_dir)/command-line-options.cpp \
- $(tizen_application_internal_src_dir)/abort-handler.cpp
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "application-impl.h"
-
-// EXTERNAL INCLUDES
-#include <Ecore_X.h>
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/adaptor-framework/common/style-monitor.h>
-
-// INTERNAL INCLUDES
-#include <internal/command-line-options.h>
-#include <internal/common/adaptor-impl.h>
-#include <internal/common/ecore-x/ecore-x-render-surface.h>
-
-namespace Dali
-{
-
-namespace SlpPlatform
-{
-class SlpPlatformAbstraction;
-}
-
-namespace Integration
-{
-class Core;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-// Defaults taken from H2 device
-const unsigned int DEFAULT_WINDOW_WIDTH = 480;
-const unsigned int DEFAULT_WINDOW_HEIGHT = 800;
-const float DEFAULT_HORIZONTAL_DPI = 220;
-const float DEFAULT_VERTICAL_DPI = 217;
-
-boost::thread_specific_ptr<Application> gThreadLocalApplication;
-}
-
-ApplicationPtr Application::New(
- int* argc,
- char **argv[],
- const std::string& name,
- const DeviceLayout& baseLayout,
- Dali::Application::WINDOW_MODE windowMode)
-{
- ApplicationPtr application ( new Application (argc, argv, name, baseLayout, windowMode ) );
- return application;
-}
-
-Application::Application(
- int* argc,
- char** argv[],
- const std::string& name,
- const DeviceLayout& baseLayout,
- Dali::Application::WINDOW_MODE windowMode)
-: mFramework(NULL),
- mCommandLineOptions(NULL),
- mAdaptor(NULL),
- mWindow(),
- mWindowMode( windowMode ),
- mName(name),
- mInitialized(false),
- mBaseLayout(baseLayout),
- mSlotDelegate( this )
-{
- // make sure we don't create the local thread application instance twice
- DALI_ASSERT_ALWAYS(gThreadLocalApplication.get() == NULL && "Cannot create more than one Application per thread" );
-
- // reset is used to store a new value associated with this thread
- gThreadLocalApplication.reset(this);
-
- mCommandLineOptions = new CommandLineOptions(argc, argv);
-
- mFramework = new Framework(*this, argc, argv, name);
-}
-
-Application::~Application()
-{
- delete mFramework;
- delete mCommandLineOptions;
- delete mAdaptor;
- mWindow.Reset();
- gThreadLocalApplication.release();
-}
-
-void Application::CreateWindow()
-{
-#ifndef __arm__
- PositionSize windowPosition(0, 0, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
-#else
- PositionSize windowPosition(0, 0, 0, 0); // this will use full screen
-#endif
- if (mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0)
- {
- // let the command line options over ride
- windowPosition = PositionSize(0,0,mCommandLineOptions->stageWidth,mCommandLineOptions->stageHeight);
- }
-
- mWindow = Dali::Window::New( windowPosition, mName, mWindowMode == Dali::Application::TRANSPARENT );
-}
-
-void Application::CreateAdaptor()
-{
- DALI_ASSERT_ALWAYS( mWindow && "Window required to create adaptor" );
-
- mAdaptor = &Dali::Adaptor::New( mWindow, mBaseLayout);
-
- // Allow DPI to be overridden from command line.
- unsigned int hDPI=DEFAULT_HORIZONTAL_DPI;
- unsigned int vDPI=DEFAULT_VERTICAL_DPI;
-
- std::string dpiStr = mCommandLineOptions->stageDPI;
- if(!dpiStr.empty())
- {
- sscanf(dpiStr.c_str(), "%ux%u", &hDPI, &vDPI);
- }
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetDpi(hDPI, vDPI);
-
- mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize );
-}
-
-void Application::MainLoop()
-{
- // Run the application
- mFramework->Run();
-}
-
-void Application::Lower()
-{
- // Lower the application without quitting it.
- mWindow.Lower();
-}
-
-void Application::Quit()
-{
- // Actually quit the application.
- AddIdle(boost::bind(&Application::QuitFromMainLoop, this));
-}
-
-void Application::QuitFromMainLoop()
-{
- mAdaptor->Stop();
-
- Dali::Application application(this);
- mTerminateSignalV2.Emit( application );
-
- mFramework->Quit();
- // This will trigger OnTerminate(), below, after the main loop has completed.
- mInitialized = false;
-}
-
-void Application::OnInit()
-{
- mFramework->AddAbortCallback(boost::bind(&Application::QuitFromMainLoop, this));
-
- CreateWindow();
- CreateAdaptor();
-
- // Run the adaptor
- mAdaptor->Start();
-
- // Check if user requires no vsyncing and set on X11 Adaptor
- if (mCommandLineOptions->noVSyncOnRender)
- {
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).DisableVSync();
- }
-
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetStereoBase( mCommandLineOptions->stereoBase );
- if( mCommandLineOptions->viewMode != 0 )
- {
- ViewMode viewMode = MONO;
- if( mCommandLineOptions->viewMode <= STEREO_INTERLACED )
- {
- viewMode = static_cast<ViewMode>( mCommandLineOptions->viewMode );
- }
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetViewMode( viewMode );
- }
-
- mInitialized = true;
-
- // in default, auto hide indicator mode
- mWindow.ShowIndicator(Dali::Window::AUTO);
-
- Dali::Application application(this);
- mInitSignalV2.Emit( application );
-}
-
-void Application::OnTerminate()
-{
- // we've been told to quit by AppCore, ecore_x_destroy has been called, need to quit synchronously
- // delete the window as ecore_x has been destroyed by AppCore
-
- mWindow.Reset();
- mInitialized = false;
-}
-
-void Application::OnPause()
-{
- mAdaptor->Pause();
- Dali::Application application(this);
- mPauseSignalV2.Emit( application );
-}
-
-void Application::OnResume()
-{
- mAdaptor->Resume();
- Dali::Application application(this);
- mResumeSignalV2.Emit( application );
-}
-
-void Application::OnReset()
-{
- /*
- * usually, reset callback was called when a caller request to launch this application via aul.
- * because Application class already handled initialization in OnInit(), OnReset do nothing.
- */
- Dali::Application application(this);
- mResetSignalV2.Emit( application );
-
- mWindow.Raise();
-}
-
-void Application::OnLanguageChanged()
-{
- mAdaptor->NotifyLanguageChanged();
-}
-
-void Application::OnResize(Dali::Adaptor& adaptor)
-{
- Dali::Application application(this);
- mResizeSignalV2.Emit( application );
-}
-
-bool Application::AddIdle(boost::function<void(void)> callBack)
-{
- return mAdaptor->AddIdle(callBack);
-}
-
-Dali::Adaptor& Application::GetAdaptor()
-{
- return *mAdaptor;
-}
-
-Dali::Window Application::GetWindow()
-{
- return mWindow;
-}
-
-Dali::Application Application::Get()
-{
- DALI_ASSERT_ALWAYS( gThreadLocalApplication.get() != NULL && "Application not instantiated" );
-
- Dali::Application application(gThreadLocalApplication.get());
-
- return application;
-}
-
-const std::string& Application::GetTheme()
-{
- return Dali::StyleMonitor::Get().GetTheme();
-}
-
-void Application::SetTheme(const std::string& themeFilePath)
-{
- return Dali::StyleMonitor::Get().SetTheme(themeFilePath);
-}
-
-// Stereoscopy
-
-void Application::SetViewMode( ViewMode viewMode )
-{
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetViewMode( viewMode );
-}
-
-ViewMode Application::GetViewMode() const
-{
- return Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).GetViewMode();
-}
-
-void Application::SetStereoBase( float stereoBase )
-{
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetStereoBase( stereoBase );
-}
-
-float Application::GetStereoBase() const
-{
- return Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).GetStereoBase();
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_APPLICATION_H__
-#define __DALI_INTERNAL_APPLICATION_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
-#include <boost/function.hpp>
-#include <boost/thread.hpp>
-
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/object/base-object.h>
-
-// INTERNAL INCLUDES
-#include <public-api/adaptor-framework/application.h>
-
-#include <internal/framework.h>
-#include <internal/common/window-impl.h>
-
-namespace Dali
-{
-class Window;
-class Adaptor;
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-class CommandLineOptions;
-class EventLoop;
-
-typedef Dali::Rect<int> PositionSize;
-
-class Application;
-typedef IntrusivePtr<Application> ApplicationPtr;
-
-/**
- * Implementation of the Application class.
- */
-class Application : public BaseObject, public Framework::Observer
-{
-public:
-
- typedef Dali::Application::AppSignalV2 AppSignalV2;
-
- /**
- * Constructor
- * @param[in] app The public instance of the Application
- * @param[in] argc A pointer to the number of arguments
- * @param[in] argv A pointer to the argument list
- * @param[in] name A name of application
- * @param[in] baseLayout The base layout that the application has been written for
- * @param[in] windowMode A member of Dali::Application::WINDOW_MODE
- */
- static ApplicationPtr New(int* argc, char **argv[], const std::string& name,
- const DeviceLayout& baseLayout,
- Dali::Application::WINDOW_MODE windowMode);
-
- Application(int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout, Dali::Application::WINDOW_MODE windowMode );
-
- /**
- * Destructor
- */
- virtual ~Application();
-
-public:
-
- /**
- * @copydoc Dali::Application::MainLoop()
- */
- void MainLoop();
-
- /**
- * @copydoc Dali::Application::Lower()
- */
- void Lower();
-
- /**
- * @copydoc Dali::Application::Quit()
- */
- void Quit();
-
- /**
- * @copydoc Dali::Application::AddIdle()
- */
- bool AddIdle(boost::function<void(void)> callBack);
-
- /**
- * @copydoc Dali::Application::GetAdaptor();
- */
- Dali::Adaptor& GetAdaptor();
-
- /**
- * @copydoc Dali::Application::GetWindow();
- */
- Dali::Window GetWindow();
-
- /**
- * @copydoc Dali::Application::Get();
- */
- static Dali::Application Get();
-
- /**
- * @copydoc Dali::Application::GetTheme();
- */
- const std::string& GetTheme();
-
- /**
- * @copydoc Dali::Application::SetTheme();
- */
- void SetTheme(const std::string& themeFilePath);
-
-public: // Stereoscopy
-
- /**
- * @copydoc Dali::Application::SetViewMode()
- */
- void SetViewMode( ViewMode viewMode );
-
- /**
- * @copydoc Dali::Application::GetViewMode()
- */
- ViewMode GetViewMode() const;
-
- /**
- * @copydoc Dali::Application::SetStereoBase()
- */
- void SetStereoBase( float stereoBase );
-
- /**
- * @copydoc Dali::Application::GetStereoBase()
- */
- float GetStereoBase() const;
-
-public: // From Framework::Observer
-
- /**
- * Called when the framework is initialised.
- */
- virtual void OnInit();
-
- /**
- * Called when the framework is terminated.
- */
- virtual void OnTerminate();
-
- /**
- * Called when the framework is paused.
- */
- virtual void OnPause();
-
- /**
- * Called when the framework resumes from a paused state.
- */
- virtual void OnResume();
-
- /**
- * Called when the framework informs the application that it should reset itself.
- */
- virtual void OnReset();
-
- /**
- * Called when the framework informs the application that the language of the device has changed.
- */
- virtual void OnLanguageChanged();
-
-public:
-
- /**
- * Signal handler when the adaptor's window resizes itself.
- * @param[in] adaptor The adaptor
- */
- void OnResize(Dali::Adaptor& adaptor);
-
-public: // Signals
-
- /**
- * @copydoc Dali::Application::InitSignal()
- */
- Dali::Application::AppSignalV2& InitSignal() { return mInitSignalV2; }
-
- /**
- * @copydoc Dali::Application::TerminateSignal()
- */
- Dali::Application::AppSignalV2& TerminateSignal() { return mTerminateSignalV2; }
-
- /**
- * @copydoc Dali::Application::PauseSignal()
- */
- Dali::Application::AppSignalV2& PauseSignal() { return mPauseSignalV2; }
-
- /**
- * @copydoc Dali::Application::ResumeSignal()
- */
- Dali::Application::AppSignalV2& ResumeSignal() { return mResumeSignalV2; }
-
- /**
- * @copydoc Dali::Application::ResetSignal()
- */
- Dali::Application::AppSignalV2& ResetSignal() { return mResetSignalV2; }
-
- /**
- * @copydoc Dali::Application::ResizeSignal()
- */
- Dali::Application::AppSignalV2& ResizeSignal() { return mResizeSignalV2; }
-
- /**
- * @copydoc Dali::Application::LanguageChangedSignal()
- */
- Dali::Application::AppSignalV2& LanguageChangedSignal() { return mLanguageChangedSignalV2; }
-
-private:
-
- // Undefined
- Application(const Application&);
- Application& operator=(Application&);
-
-private:
- /**
- * Creates the window
- */
- void CreateWindow();
-
- /**
- * Creates the adaptor
- */
- void CreateAdaptor();
-
- /**
- * Quits from the main loop
- */
- void QuitFromMainLoop();
-
-private:
-
- AppSignalV2 mInitSignalV2;
- AppSignalV2 mTerminateSignalV2;
- AppSignalV2 mPauseSignalV2;
- AppSignalV2 mResumeSignalV2;
- AppSignalV2 mResetSignalV2;
- AppSignalV2 mResizeSignalV2;
- AppSignalV2 mLanguageChangedSignalV2;
-
- EventLoop* mEventLoop;
- Framework* mFramework;
-
- CommandLineOptions* mCommandLineOptions;
-
- Dali::Adaptor* mAdaptor;
- Dali::Window mWindow;
- Dali::Application::WINDOW_MODE mWindowMode;
- std::string mName;
-
- bool mInitialized;
- DeviceLayout mBaseLayout;
-
- SlotDelegate< Application > mSlotDelegate;
-};
-
-inline Application& GetImplementation(Dali::Application& application)
-{
- DALI_ASSERT_ALWAYS(application && "application handle is empty");
-
- BaseObject& handle = application.GetBaseObject();
-
- return static_cast<Internal::Adaptor::Application&>(handle);
-}
-
-inline const Application& GetImplementation(const Dali::Application& application)
-{
- DALI_ASSERT_ALWAYS(application && "Timre handle is empty");
-
- const BaseObject& handle = application.GetBaseObject();
-
- return static_cast<const Internal::Adaptor::Application&>(handle);
-}
-
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_APPLICATION_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "command-line-options.h"
-
-// EXTERNAL INCLUDES
-#include <getopt.h>
-#include <stdlib.h>
-#include <string.h>
-#include <iostream>
-
-#include <dali/public-api/common/vector-wrapper.h>
-
-using namespace std;
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-struct Argument
-{
- const char * const opt;
- const char * const optDescription;
-
- void Print()
- {
- const ios_base::fmtflags flags = cout.flags();
- cout << left << " --";
- cout.width( 18 );
- cout << opt;
- cout << optDescription;
- cout << endl;
- cout.flags( flags );
- }
-};
-
-Argument EXPECTED_ARGS[] =
-{
- { "no-vsync", "Disable VSync on Render" },
- { "width", "Stage Width" },
- { "height", "Stage Height" },
- { "dpi", "Emulated DPI" },
- { "view", "Stereocopic 3D view mode ([0]=MONO, 1=STEREO_HORZ, 2=STEREO_VERT, 3=STEREO_INTERLACED)" },
- { "stereo-base", "Distance in millimeters between left/right cameras [65.0]" },
- { "help", "Help" },
- { NULL, NULL }
-};
-
-enum Option
-{
- OPTION_NO_VSYNC = 0,
- OPTION_STAGE_WIDTH,
- OPTION_STAGE_HEIGHT,
- OPTION_DPI,
- OPTION_STEREO_MODE,
- OPTION_STEREO_BASE,
- OPTION_HELP
-};
-
-typedef vector< int > UnhandledContainer;
-
-void ShowHelp()
-{
- cout << "Available options:" << endl;
- Argument* arg = EXPECTED_ARGS;
- while ( arg->opt )
- {
- arg->Print();
- ++arg;
- }
-}
-
-} // unnamed namespace
-
-CommandLineOptions::CommandLineOptions(int *argc, char **argv[])
-: noVSyncOnRender(0),
- stageWidth(0), stageHeight(0),
- viewMode(0),
- stereoBase(65)
-{
- if ( *argc > 1 )
- {
- // We do not want to print out errors.
- int origOptErrValue( opterr );
- opterr = 0;
-
- int help( 0 );
-
- const struct option options[]=
- {
- { EXPECTED_ARGS[OPTION_NO_VSYNC].opt, no_argument, &noVSyncOnRender, 1 }, // "--no-vsync"
- { EXPECTED_ARGS[OPTION_STAGE_WIDTH].opt, required_argument, NULL, 'w' }, // "--width"
- { EXPECTED_ARGS[OPTION_STAGE_HEIGHT].opt, required_argument, NULL, 'h' }, // "--height"
- { EXPECTED_ARGS[OPTION_DPI].opt, required_argument, NULL, 'd' }, // "--dpi"
- { EXPECTED_ARGS[OPTION_STEREO_MODE].opt, required_argument, NULL, 'v' }, // "--view"
- { EXPECTED_ARGS[OPTION_STEREO_BASE].opt, required_argument, NULL, 's' }, // "--stereo-base"
- { EXPECTED_ARGS[OPTION_HELP].opt, no_argument, &help, '?' }, // "--help"
- { 0, 0, 0, 0 } // end of options
- };
-
- int shortOption( 0 );
- int optionIndex( 0 );
-
- const char* optString = "-w:h:d:v:s:"; // The '-' ensures that argv is NOT permuted
- bool optionProcessed( false );
-
- UnhandledContainer unhandledOptions; // We store indices of options we do not handle here
-
- do
- {
- shortOption = getopt_long( *argc, *argv, optString, options, &optionIndex );
-
- switch ( shortOption )
- {
- case 0:
- {
- // Check if we want help
- if ( help )
- {
- ShowHelp();
- optionProcessed = true;
- }
- break;
- }
-
- case 'w':
- {
- if ( optarg )
- {
- stageWidth = atoi( optarg );
- optionProcessed = true;
- }
- break;
- }
-
- case 'h':
- {
- if ( optarg )
- {
- stageHeight = atoi( optarg );
- optionProcessed = true;
- }
- break;
- }
-
- case 'd':
- {
- if ( optarg )
- {
- stageDPI.assign( optarg );
- optionProcessed = true;
- }
- break;
- }
-
- case 'v':
- {
- if ( optarg )
- {
- viewMode = atoi(optarg);
- optionProcessed = true;
- }
- break;
- }
-
- case 's':
- {
- if ( optarg )
- {
- stereoBase = atoi(optarg);
- optionProcessed = true;
- }
- break;
- }
-
- case -1:
- {
- // All command-line options have been parsed.
- break;
- }
-
- default:
- {
- unhandledOptions.push_back( optind - 1 );
- break;
- }
- }
- } while ( shortOption != -1 );
-
- // Take out the options we have processed
- if ( optionProcessed )
- {
- if ( !unhandledOptions.empty() )
- {
- int index( 1 );
-
- // Overwrite the argv with the values from the unhandled indices
- const UnhandledContainer::const_iterator endIter = unhandledOptions.end();
- for ( UnhandledContainer::iterator iter = unhandledOptions.begin(); iter != endIter; ++iter )
- {
- (*argv)[ index++ ] = (*argv)[ *iter ];
- }
- *argc = unhandledOptions.size() + 1; // +1 for the program name
- }
- else
- {
- // There are no unhandled options, so we should just have the program name
- *argc = 1;
- }
-
- optind = 1; // Reset to start
- }
-
- opterr = origOptErrValue; // Reset opterr value.
- }
-}
-
-CommandLineOptions::~CommandLineOptions()
-{
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_COMMAND_LINE_OPTIONS_H__
-#define __DALI_INTERNAL_COMMAND_LINE_OPTIONS_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Parses the passed command line arguments and sets the values stored within this
- * class appropriately.
- *
- * The following options are supported:
- *
- * @code
- * --no-vsync Disable VSync on Render
- * -w|--width Stage Width
- * -h|--height Stage Height
- * -d|--dpi Emulated DPI
- * --help Help
- * @endcode
- *
- * When the above options are found, they are stripped from argv, and argc is updated appropriately.
- */
-struct CommandLineOptions
-{
-public:
-
- /**
- * Constructor
- * @param[in,out] argc The number of arguments
- * @param[in,out] argv The argument list
- * @note Supported options are stripped from argv, and argc is updated appropriately.
- */
- CommandLineOptions(int *argc, char **argv[]);
-
- /**
- * Destructor
- */
- ~CommandLineOptions();
-
-public: // Command line parsed values
-
- int noVSyncOnRender; ///< If 1, then the user does not want VSync on Render
- int stageWidth; ///< The width of the stage required. 0 if not set.
- int stageHeight; ///< The height of the stage required. 0 if not set.
- int viewMode; ///< Stereocopic 3D view mode (0=MONO, 1=STEREO_HORZ, 2=STEREO_VERT, 3=STEREO_INTERLACED)
- int stereoBase; ///< The distance in millimeters between left/right cameras
- std::string stageDPI; ///< DPI stored as hxv, where h is horizontal DPI and v is vertical DPI
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_COMMAND_LINE_OPTIONS_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "accessibility-gesture-detector.h"
-
-// EXTERNAL INCLUDES
-
-// INTERNAL INCLUDES
-#include <dali/integration-api/events/gesture-requests.h>
-#include <internal/common/accessibility-manager-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-AccessibilityGestureDetector::AccessibilityGestureDetector()
-: PanGestureDetectorBase(Vector2::ZERO, Integration::PanGestureRequest(), NULL),
- mGestureHandler(NULL),
- mPanning(false)
-{
-}
-
-AccessibilityGestureDetector::~AccessibilityGestureDetector()
-{
-}
-
-void AccessibilityGestureDetector::SetGestureHandler(AccessibilityGestureHandler& handler)
-{
- mGestureHandler = &handler;
-}
-
-void AccessibilityGestureDetector::EmitPan(const Integration::PanGestureEvent gesture)
-{
- if( mGestureHandler )
- {
- if(gesture.state == Gesture::Started)
- {
- mPanning = true;
- }
-
- if( mPanning )
- {
- mGestureHandler->HandlePanGesture(gesture);
-
- if( (gesture.state == Gesture::Finished) ||
- (gesture.state == Gesture::Cancelled) )
- {
- mPanning = false;
- }
- }
- }
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ACCESSIBILITY_GESTURE_DETECTOR_H__
-#define __DALI_INTERNAL_ACCESSIBILITY_GESTURE_DETECTOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-
-// INTERNAL INCLUDES
-#include <internal/common/events/pan-gesture-detector-base.h>
-#include <internal/common/adaptor-impl.h>
-#include <public-api/adaptor-framework/common/accessibility-gesture-handler.h>
-
-namespace Dali
-{
-
-namespace Integration
-{
-class Core;
-struct TouchEvent;
-struct PanGestureRequest;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Detects an accessibility pan gesture and sends it to the gesture handler.
- */
-class AccessibilityGestureDetector : public PanGestureDetectorBase
-{
-public:
-
- /**
- * Constructor
- */
- AccessibilityGestureDetector();
-
- /**
- * Virtual destructor.
- */
- virtual ~AccessibilityGestureDetector();
-
- /**
- * Set the handler to handle accessibility gestures.
- * @param[in] handler The Accessibility gesture handler.
- * @note Handlers should remove themselves when they are destroyed.
- */
- void SetGestureHandler(AccessibilityGestureHandler& handler);
-
-private:
-
- /**
- * Emits the pan gesture event to the gesture handler.
- * @param[in] gesture The pan gesture event.
- */
- virtual void EmitPan(const Integration::PanGestureEvent gesture);
-
-private:
-
- AccessibilityGestureHandler* mGestureHandler; ///< The pointer of accessibility gesture handler
- bool mPanning; ///< Keep track of panning state, when panning is occuring, this is true.
-};
-
-typedef IntrusivePtr<AccessibilityGestureDetector> AccessibilityGestureDetectorPtr;
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ACCESSIBILITY_GESTURE_DETECTOR_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "accessibility-manager-impl.h"
-
-// EXTERNAL INCLUDES
-#include <vconf.h>
-#include <Ecore_X.h>
-#include <Elementary.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali/integration-api/debug.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/gesture-requests.h>
-#include "system-settings.h"
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gAccessibilityManagerLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_MANAGER");
-#endif
-
-void AccessibilityOnOffNotification(keynode_t* node, void* data)
-{
- AccessibilityManager* manager = static_cast<AccessibilityManager*>(data);
- int isEnabled = 0;
- vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &isEnabled);
-
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled?"ENABLED":"DISABLED");
-
- if(isEnabled == 1)
- {
- manager->EnableAccessibility();
- }
- else
- {
- manager->DisableAccessibility();
- }
-}
-
-BaseHandle Create()
-{
- BaseHandle handle( AccessibilityManager::Get() );
-
- if ( !handle && Adaptor::IsAvailable() )
- {
- Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
- Dali::AccessibilityManager manager = Dali::AccessibilityManager( new AccessibilityManager() );
- adaptorImpl.RegisterSingleton( typeid( manager ), manager );
- handle = manager;
- }
-
- return handle;
-}
-TypeRegistration ACCESSIBILITY_MANAGER_TYPE( typeid(Dali::AccessibilityManager), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
-
-} // unnamed namespace
-
-Dali::AccessibilityManager AccessibilityManager::Get()
-{
- Dali::AccessibilityManager manager;
-
- if ( Adaptor::IsAvailable() )
- {
- // Check whether the singleton is already created
- Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::AccessibilityManager ) );
- if(handle)
- {
- // If so, downcast the handle
- manager = Dali::AccessibilityManager( dynamic_cast< AccessibilityManager* >( handle.GetObjectPtr() ) );
- }
- }
-
- return manager;
-}
-
-Vector2 AccessibilityManager::GetReadPosition() const
-{
- return mReadPosition;
-}
-
-void AccessibilityManager::SetActionHandler(AccessibilityActionHandler& handler)
-{
- mActionHandler = &handler;
-}
-
-void AccessibilityManager::SetGestureHandler(AccessibilityGestureHandler& handler)
-{
- if( mAccessibilityGestureDetector )
- {
- mAccessibilityGestureDetector->SetGestureHandler(handler);
- }
-}
-
-bool AccessibilityManager::HandleActionNextEvent(bool allowEndFeedback)
-{
- bool ret = false;
- Dali::AccessibilityManager handle( this );
-
- /*
- * In order to application decide reading action first,
- * emit ActionNext signal in first, AccessibilityActionNext for handler in next
- */
- if( !mIndicatorFocused )
- {
- if( !mActionNextSignalV2.Empty() )
- {
- mActionNextSignalV2.Emit( handle );
- }
- }
-
- if( mIndicator && mIndicatorFocused )
- {
- Elm_Access_Action_Info actionInfo;
- actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
-
- ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
- }
- else if( mActionHandler )
- {
- ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
- }
-
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
-
- return ret;
-}
-
-bool AccessibilityManager::HandleActionPreviousEvent(bool allowEndFeedback)
-{
- bool ret = false;
-
- Dali::AccessibilityManager handle( this );
-
- /*
- * In order to application decide reading action first,
- * emit ActionPrevious signal in first, AccessibilityActionPrevious for handler in next
- */
- if ( !mIndicatorFocused )
- {
- if( !mActionPreviousSignalV2.Empty() )
- {
- mActionPreviousSignalV2.Emit( handle );
- }
- }
-
- if( mIndicator && mIndicatorFocused )
- {
- Elm_Access_Action_Info actionInfo;
- actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
-
- ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
- }
- else if( mActionHandler )
- {
- ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
- }
-
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
-
- return ret;
-}
-
-bool AccessibilityManager::HandleActionActivateEvent()
-{
- bool ret = false;
-
- Dali::AccessibilityManager handle( this );
-
- /*
- * In order to application decide reading action first,
- * emit ActionActivate signal in first, AccessibilityActionActivate for handler in next
- */
- if ( !mIndicatorFocused )
- {
- if( !mActionActivateSignalV2.Empty() )
- {
- mActionActivateSignalV2.Emit( handle );
- }
- }
-
- if( mIndicator && mIndicatorFocused )
- {
- Elm_Access_Action_Info actionInfo;
- actionInfo.action_type = ELM_ACCESS_ACTION_ACTIVATE;
-
- ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
- }
- else if( mActionHandler )
- {
- ret = mActionHandler->AccessibilityActionActivate();
- }
-
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
-
- return ret;
-}
-
-bool AccessibilityManager::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
-{
- bool ret = false;
-
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
-
- mReadPosition.x = x;
- mReadPosition.y = y;
-
- Dali::AccessibilityManager handle( this );
-
- bool indicatorFocused = false;
-
- // Check whether the Indicator is focused
- if( mIndicator && mIndicator->IsConnected() )
- {
- // Check the position and size of Indicator actor
- Dali::Actor indicatorActor = mIndicator->GetActor();
- Vector3 position = Vector3(0.0f, 0.0f, 0.0f);
- Vector3 size = indicatorActor.GetCurrentSize();
-
- if(mReadPosition.x >= position.x &&
- mReadPosition.x <= position.x + size.width &&
- mReadPosition.y >= position.y &&
- mReadPosition.y <= position.y + size.height)
- {
- indicatorFocused = true;
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Indicator area!!!!\n", __FUNCTION__, __LINE__);
- }
- }
-
- if( mIndicator )
- {
- if( !mIndicatorFocused && indicatorFocused )
- {
- // If Indicator is focused, the focus should be cleared in Dali focus chain.
- if( mActionHandler )
- {
- mActionHandler->ClearAccessibilityFocus();
- }
- }
- else if( mIndicatorFocused && !indicatorFocused )
- {
- Elm_Access_Action_Info actionInfo;
- actionInfo.action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
-
- // Indicator should be unhighlighted
- ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Send unhighlight message to indicator!!!!\n", __FUNCTION__, __LINE__);
- }
-
- mIndicatorFocused = indicatorFocused;
-
- // Send accessibility READ action information to Indicator
- if( mIndicatorFocused )
- {
- Elm_Access_Action_Info actionInfo;
- actionInfo.x = mReadPosition.x;
- actionInfo.y = mReadPosition.y;
-
- if(allowReadAgain)
- {
- actionInfo.action_type = ELM_ACCESS_ACTION_READ;
- }
- else
- {
- actionInfo.action_type = static_cast<Elm_Access_Action_Type>( GetElmAccessActionOver() );
- }
-
- ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
-
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Send READ message to indicator!!!!\n", __FUNCTION__, __LINE__);
- }
- }
-
- if(allowReadAgain)
- {
- /*
- * In order to application decide reading action first,
- * emit ActionRead signal in first, AccessibilityActionRead for handler in next
- */
- if( !mIndicatorFocused )
- {
- if ( !mActionReadSignalV2.Empty() )
- {
- mActionReadSignalV2.Emit( handle );
- }
- }
- }
- else
- {
- /*
- * In order to application decide reading action first,
- * emit ActionRead signal in first, AccessibilityActionRead for handler in next
- */
- if( !mIndicatorFocused )
- {
- if ( !mActionOverSignalV2.Empty() )
- {
- mActionOverSignalV2.Emit( handle );
- }
- }
- }
-
- if( mActionHandler && !mIndicatorFocused)
- {
- // If Indicator is not focused, the accessibility actions should be handled by the registered
- // accessibility action handler (e.g. focus manager)
- ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
- }
-
- return ret;
-}
-
-bool AccessibilityManager::HandleActionReadNextEvent(bool allowEndFeedback)
-{
- bool ret = false;
-
- Dali::AccessibilityManager handle( this );
-
- /*
- * In order to application decide reading action first,
- * emit ActionReadNext signal in first, AccessibilityActionReadNext for handler in next
- */
- if ( !mIndicatorFocused )
- {
- if( !mActionReadNextSignalV2.Empty() )
- {
- mActionReadNextSignalV2.Emit( handle );
- }
- }
-
- if( mIndicator && mIndicatorFocused )
- {
- Elm_Access_Action_Info actionInfo;
- actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
-
- ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
- }
- else if( mActionHandler )
- {
- ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
- }
-
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
-
- return ret;
-}
-
-bool AccessibilityManager::HandleActionReadPreviousEvent(bool allowEndFeedback)
-{
- bool ret = false;
-
- Dali::AccessibilityManager handle( this );
-
- /*
- * In order to application decide reading action first,
- * emit ActionReadPrevious signal in first, AccessibilityActionReadPrevious for handler in next
- */
- if ( !mIndicatorFocused )
- {
- if( !mActionReadPreviousSignalV2.Empty() )
- {
- mActionReadPreviousSignalV2.Emit( handle );
- }
- }
-
- if( mIndicator && mIndicatorFocused )
- {
- Elm_Access_Action_Info actionInfo;
- actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
-
- ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
- }
- else if( mActionHandler )
- {
- ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
- }
-
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
-
- return ret;
-}
-
-bool AccessibilityManager::HandleActionUpEvent()
-{
- bool ret = false;
-
- Dali::AccessibilityManager handle( this );
-
- /*
- * In order to application decide reading action first,
- * emit ActionUp signal in first, AccessibilityActionUp for handler in next
- */
- if ( !mIndicatorFocused )
- {
- if( !mActionUpSignalV2.Empty() )
- {
- mActionUpSignalV2.Emit( handle );
- }
- }
-
- if( mIndicator && mIndicatorFocused )
- {
- Elm_Access_Action_Info actionInfo;
- actionInfo.action_type = ELM_ACCESS_ACTION_UP;
-
- ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
- }
- else if( mActionHandler )
- {
- ret = mActionHandler->AccessibilityActionUp();
- }
-
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
-
- return ret;
-}
-
-bool AccessibilityManager::HandleActionDownEvent()
-{
- bool ret = false;
-
- Dali::AccessibilityManager handle( this );
-
- /*
- * In order to application decide reading action first,
- * emit ActionDown signal in first, AccessibilityActionDown for handler in next
- */
- if ( !mIndicatorFocused )
- {
- if( !mActionDownSignalV2.Empty() )
- {
- mActionDownSignalV2.Emit( handle );
- }
- }
-
- if( mIndicator && mIndicatorFocused )
- {
- Elm_Access_Action_Info actionInfo;
- actionInfo.action_type = ELM_ACCESS_ACTION_DOWN;
-
- ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
- }
- else if( mActionHandler )
- {
- ret = mActionHandler->AccessibilityActionDown();
- }
-
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
-
- return ret;
-}
-
-bool AccessibilityManager::HandleActionClearFocusEvent()
-{
- bool ret = false;
-
- Dali::AccessibilityManager handle( this );
-
- /*
- * In order to application decide reading action first,
- * emit ActionClearFocus signal in first, ClearAccessibilityFocus for handler in next
- */
- if ( !mIndicatorFocused )
- {
- if( !mActionClearFocusSignalV2.Empty() )
- {
- mActionClearFocusSignalV2.Emit( handle );
- }
- }
-
- if( mActionHandler )
- {
- ret = mActionHandler->ClearAccessibilityFocus();
- }
-
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
-
- return ret;
-}
-
-bool AccessibilityManager::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
-{
- bool ret = false;
-
- Dali::AccessibilityManager handle( this );
-
- Dali::TouchEvent touchEvent(timeStamp);
- touchEvent.points.push_back(point);
-
- /*
- * In order to application decide touch action first,
- * emit ActionScroll signal in first, AccessibilityActionScroll for handler in next
- */
- if ( !mIndicatorFocused )
- {
- if( !mActionScrollSignalV2.Empty() )
- {
- mActionScrollSignalV2.Emit( handle, touchEvent );
- }
- }
-
- Integration::TouchEvent event;
- if (mCombiner.GetNextTouchEvent(point, timeStamp, event))
- {
- // Process the touch event in accessibility gesture detector
- if( mAccessibilityGestureDetector )
- {
- mAccessibilityGestureDetector->SendEvent(event);
- ret = true;
- }
- }
-
- return ret;
-}
-
-bool AccessibilityManager::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
-{
- bool ret = false;
-
- Dali::TouchEvent touchEvent(timeStamp);
- touchEvent.points.push_back(point);
-
- if( mActionHandler )
- {
- ret = mActionHandler->AccessibilityActionTouch(touchEvent);
- }
- return ret;
-}
-
-bool AccessibilityManager::HandleActionBackEvent()
-{
- bool ret = false;
-
- Dali::AccessibilityManager handle( this );
-
- /*
- * In order to application decide reading action first,
- * emit ActionBack signal in first, AccessibilityActionBack for handler in next
- */
- if ( !mIndicatorFocused )
- {
- if( !mActionBackSignalV2.Empty() )
- {
- mActionBackSignalV2.Emit( handle );
- }
- }
-
- if( mActionHandler )
- {
- ret = mActionHandler->AccessibilityActionBack();
- }
-
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
-
- return ret;
-}
-
-void AccessibilityManager::HandleActionEnableEvent()
-{
- EnableAccessibility();
-}
-
-void AccessibilityManager::HandleActionDisableEvent()
-{
- DisableAccessibility();
-}
-
-void AccessibilityManager::EnableAccessibility()
-{
- if(mIsEnabled == false)
- {
- mIsEnabled = true;
-
- if( mActionHandler )
- {
- mActionHandler->ChangeAccessibilityStatus();
- }
-
- //emit status changed signal
- Dali::AccessibilityManager handle( this );
- mStatusChangedSignalV2.Emit( handle );
- }
-}
-
-void AccessibilityManager::DisableAccessibility()
-{
- if(mIsEnabled == true)
- {
- mIsEnabled = false;
-
- if( mActionHandler )
- {
- mActionHandler->ChangeAccessibilityStatus();
- }
-
- //emit status changed signal
- Dali::AccessibilityManager handle( this );
- mStatusChangedSignalV2.Emit( handle );
-
- // Destroy the TtsPlayer if exists.
- Dali::Adaptor& adaptor = Dali::Adaptor::Get();
- Adaptor::GetImplementation(adaptor).DestroyTtsPlayer(Dali::TtsPlayer::SCREEN_READER);
- }
-}
-
-bool AccessibilityManager::IsEnabled() const
-{
- return mIsEnabled;
-}
-
-void AccessibilityManager::SetIndicator(Indicator* indicator)
-{
- mIndicator = indicator;
-}
-
-AccessibilityManager::AccessibilityManager()
-: mIsEnabled(false),
- mActionHandler(NULL),
- mIndicator(NULL),
- mIndicatorFocused(false)
-{
- int isEnabled = 0;
- vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &isEnabled);
- DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, isEnabled?"ENABLED":"DISABLED");
-
- if(isEnabled == 1)
- {
- mIsEnabled = true;
- }
- else
- {
- mIsEnabled = false;
- }
-
- vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification, this );
-
- mAccessibilityGestureDetector = new AccessibilityGestureDetector();
-}
-
-AccessibilityManager::~AccessibilityManager()
-{
- vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, AccessibilityOnOffNotification );
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ACCESSIBILITY_MANAGER_H__
-#define __DALI_INTERNAL_ACCESSIBILITY_MANAGER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/events/touch-point.h>
-#include <dali/integration-api/events/touch-event-combiner.h>
-#include <dali/public-api/adaptor-framework/common/accessibility-manager.h>
-
-// INTERNAL INCLUDES
-#include <public-api/adaptor-framework/common/accessibility-action-handler.h>
-#include <public-api/adaptor-framework/common/accessibility-gesture-handler.h>
-#include <internal/common/indicator-impl.h>
-#include <internal/common/accessibility-gesture-detector.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * This class detects to accessibility action
- */
-class AccessibilityManager : public Dali::BaseObject
-{
-public:
-
- typedef Dali::AccessibilityManager::AccessibilityActionSignalV2 AccessibilityActionSignalV2;
- typedef Dali::AccessibilityManager::AccessibilityActionScrollSignalV2 AccessibilityActionScrollSignalV2;
-
- // Creation
-
- /**
- * Constructor.
- */
- AccessibilityManager();
-
- /**
- * Get an instance of the AccessibilityManager.
- * @return The instance of the AccessibilityManager.
- */
- static Dali::AccessibilityManager Get();
-
- // Public API
-
- /**
- * Turn on accessibility action
- * This method should be called by vconf callback
- */
- void EnableAccessibility();
-
- /**
- * Turn off accessibility action
- * This method should be called by vconf callback
- */
- void DisableAccessibility();
-
- /**
- * @copydoc Dali::AccessibilityManager::IsEnabled()
- */
- bool IsEnabled() const;
-
- /**
- * @copydoc Dali::AccessibilityManager::GetReadPosition() const
- */
- Vector2 GetReadPosition() const;
-
- /**
- * @copydoc Dali::AccessibilityManager::SetActionHandler()
- */
- void SetActionHandler(AccessibilityActionHandler& handler);
-
- /**
- * @copydoc Dali::AccessibilityManager::SetGestureHandler()
- */
- void SetGestureHandler(AccessibilityGestureHandler& handler);
-
- /**
- * Set the Indicator
- */
- void SetIndicator(Indicator* indicator);
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionNextEvent()
- */
- bool HandleActionNextEvent(bool allowEndFeedback = true);
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionPreviousEvent()
- */
- bool HandleActionPreviousEvent(bool allowEndFeedback = true);
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionActivateEvent()
- */
- bool HandleActionActivateEvent();
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionReadEvent()
- */
- bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionReadNextEvent()
- */
- bool HandleActionReadNextEvent(bool allowEndFeedback = true);
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionReadPreviousEvent()
- */
- bool HandleActionReadPreviousEvent(bool allowEndFeedback = true);
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionUpEvent()
- */
- bool HandleActionUpEvent();
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionDownEvent()
- */
- bool HandleActionDownEvent();
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionClearFocusEvent()
- */
- bool HandleActionClearFocusEvent();
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionScrollEvent()
- */
- bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionTouchEvent()
- */
- bool HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp);
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionBackEvent()
- */
- bool HandleActionBackEvent();
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionEnableEvent()
- */
- void HandleActionEnableEvent();
-
- /**
- * @copydoc Dali::AccessibilityManager::HandleActionDisableEvent()
- */
- void HandleActionDisableEvent();
-
-public: // Signals
-
- /**
- * @copydoc Dali::AccessibilityManager::StatusChangedSignal
- */
- AccessibilityActionSignalV2& StatusChangedSignal()
- {
- return mStatusChangedSignalV2;
- }
-
- /**
- * @copydoc Dali::AccessibilityManager::ActionNextSignal
- */
- AccessibilityActionSignalV2& ActionNextSignal()
- {
- return mActionNextSignalV2;
- }
-
- /**
- * @copydoc Dali::AccessibilityManager::ActionPreviousSignal
- */
- AccessibilityActionSignalV2& ActionPreviousSignal()
- {
- return mActionPreviousSignalV2;
- }
-
- /**
- * @copydoc Dali::AccessibilityManager::ActionActivateSignal
- */
- AccessibilityActionSignalV2& ActionActivateSignal()
- {
- return mActionActivateSignalV2;
- }
-
- /**
- * @copydoc Dali::AccessibilityManager::ActionOverSignal
- */
- AccessibilityActionSignalV2& ActionOverSignal()
- {
- return mActionOverSignalV2;
- }
-
- /**
- * @copydoc Dali::AccessibilityManager::ActionReadSignal
- */
- AccessibilityActionSignalV2& ActionReadSignal()
- {
- return mActionReadSignalV2;
- }
-
- /**
- * @copydoc Dali::AccessibilityManager::ActionReadNextSignal
- */
- AccessibilityActionSignalV2& ActionReadNextSignal()
- {
- return mActionReadNextSignalV2;
- }
-
- /**
- * @copydoc Dali::AccessibilityManager::ActionReadPreviousSignal
- */
- AccessibilityActionSignalV2& ActionReadPreviousSignal()
- {
- return mActionReadPreviousSignalV2;
- }
-
- /**
- * @copydoc Dali::AccessibilityManager::ActionUpSignal
- */
- AccessibilityActionSignalV2& ActionUpSignal()
- {
- return mActionUpSignalV2;
- }
-
- /**
- * @copydoc Dali::AccessibilityManager::ActionDownSignal
- */
- AccessibilityActionSignalV2& ActionDownSignal()
- {
- return mActionDownSignalV2;
- }
-
- /**
- * @copydoc Dali::AccessibilityManager::ActionClearFocusSignal
- */
- AccessibilityActionSignalV2& ActionClearFocusSignal()
- {
- return mActionClearFocusSignalV2;
- }
-
- /**
- * @copydoc Dali::AccessibilityManager::ActionBackSignal
- */
- AccessibilityActionSignalV2& ActionBackSignal()
- {
- return mActionBackSignalV2;
- }
-
- /**
- * @copydoc Dali::AccessibilityManager::ActionScrollSignal
- */
- AccessibilityActionScrollSignalV2& ActionScrollSignal()
- {
- return mActionScrollSignalV2;
- }
-
-private:
-
- // Destruction
-
- /**
- * Destructor.
- */
- virtual ~AccessibilityManager();
-
- // Undefined
- AccessibilityManager( const AccessibilityManager& );
- AccessibilityManager& operator=( AccessibilityManager& );
-
-private:
-
- Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
-
- bool mIsEnabled; ///< enable/disable the accessibility action
- Vector2 mReadPosition; ///< ActionRead position
-
- AccessibilityActionHandler* mActionHandler; ///< The pointer of accessibility action handler
-
- AccessibilityGestureDetectorPtr mAccessibilityGestureDetector; ///< The accessibility gesture detector
-
- Indicator* mIndicator; ///< The indicator
- bool mIndicatorFocused; ///< Whether the Indicator is focused
-
- AccessibilityActionSignalV2 mStatusChangedSignalV2;
- AccessibilityActionSignalV2 mActionNextSignalV2;
- AccessibilityActionSignalV2 mActionPreviousSignalV2;
- AccessibilityActionSignalV2 mActionActivateSignalV2;
- AccessibilityActionSignalV2 mActionOverSignalV2;
- AccessibilityActionSignalV2 mActionReadSignalV2;
- AccessibilityActionSignalV2 mActionReadNextSignalV2;
- AccessibilityActionSignalV2 mActionReadPreviousSignalV2;
- AccessibilityActionSignalV2 mActionUpSignalV2;
- AccessibilityActionSignalV2 mActionDownSignalV2;
- AccessibilityActionSignalV2 mActionClearFocusSignalV2;
- AccessibilityActionSignalV2 mActionBackSignalV2;
- AccessibilityActionScrollSignalV2 mActionScrollSignalV2;
-
-public:
-
- // Helpers for public-api forwarding methods
-
- inline static Internal::Adaptor::AccessibilityManager& GetImplementation(Dali::AccessibilityManager& manager)
- {
- DALI_ASSERT_ALWAYS( manager && "AccessibilityManager handle is empty" );
-
- BaseObject& handle = manager.GetBaseObject();
-
- return static_cast<Internal::Adaptor::AccessibilityManager&>(handle);
- }
-
- inline static const Internal::Adaptor::AccessibilityManager& GetImplementation(const Dali::AccessibilityManager& manager)
- {
- DALI_ASSERT_ALWAYS( manager && "AccessibilityManager handle is empty" );
-
- const BaseObject& handle = manager.GetBaseObject();
-
- return static_cast<const Internal::Adaptor::AccessibilityManager&>(handle);
- }
-
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ACCESSIBILITY_MANAGER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "adaptor-impl.h"
-
-// EXTERNAL INCLUDES
-#include <boost/thread/tss.hpp>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/integration-api/debug.h>
-#include <dali/integration-api/core.h>
-#include <dali/integration-api/profiling.h>
-#include <dali/integration-api/input-options.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-
-// INTERNAL INCLUDES
-#include <base/update-render-controller.h>
-#include <base/environment-variables.h>
-#include <base/performance-logging/performance-interface-factory.h>
-#include <base/lifecycle-observer.h>
-
-#include <internal/common/callback-manager.h>
-#include <internal/common/trigger-event.h>
-#include <internal/common/render-surface-impl.h>
-#include <internal/common/tts-player-impl.h>
-#include <internal/common/accessibility-manager-impl.h>
-#include <internal/common/timer-impl.h>
-#include <internal/common/events/gesture-manager.h>
-#include <internal/common/events/event-handler.h>
-#include <internal/common/feedback/feedback-controller.h>
-#include <internal/common/feedback/feedback-plugin-proxy.h>
-#include <internal/common/gl/gl-implementation.h>
-#include <internal/common/gl/gl-proxy-implementation.h>
-#include <internal/common/gl/egl-sync-implementation.h>
-#include <internal/common/gl/egl-image-extensions.h>
-#include <internal/common/gl/egl-factory.h>
-#include <internal/common/imf-manager-impl.h>
-#include <internal/common/clipboard-impl.h>
-#include <internal/common/vsync-monitor.h>
-#include <internal/common/object-profiler.h>
-
-#include <slp-logging.h>
-
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-boost::thread_specific_ptr<Adaptor> gThreadLocalAdaptor;
-
-unsigned int GetIntegerEnvironmentVariable( const char* variable, unsigned int defaultValue )
-{
- const char* variableParameter = std::getenv(variable);
-
- // if the parameter exists convert it to an integer, else return the default value
- unsigned int intValue = variableParameter ? atoi(variableParameter) : defaultValue;
- return intValue;
-}
-
-bool GetIntegerEnvironmentVariable( const char* variable, int& intValue )
-{
- const char* variableParameter = std::getenv(variable);
-
- if( !variableParameter )
- {
- return false;
- }
- // if the parameter exists convert it to an integer, else return the default value
- intValue = atoi(variableParameter);
- return true;
-}
-
-bool GetBooleanEnvironmentVariable( const char* variable, bool& boolValue )
-{
- const char* variableParameter = std::getenv(variable);
-
- boolValue = variableParameter ? true : false;
- return boolValue;
-}
-
-bool GetFloatEnvironmentVariable( const char* variable, float& floatValue )
-{
- const char* variableParameter = std::getenv(variable);
-
- if( !variableParameter )
- {
- return false;
- }
- // if the parameter exists convert it to an integer, else return the default value
- floatValue = atof(variableParameter);
- return true;
-}
-
-} // unnamed namespace
-
-Dali::Adaptor* Adaptor::New( RenderSurface *surface, const DeviceLayout& baseLayout )
-{
- DALI_ASSERT_ALWAYS( surface->GetType() != Dali::RenderSurface::NO_SURFACE && "No surface for adaptor" );
-
- Dali::Adaptor* adaptor = new Dali::Adaptor;
- Adaptor* impl = new Adaptor( *adaptor, surface, baseLayout );
- adaptor->mImpl = impl;
-
- impl->Initialize();
-
- return adaptor;
-}
-
-void Adaptor::ParseEnvironmentOptions()
-{
- // get logging options
- unsigned int logFrameRateFrequency = GetIntegerEnvironmentVariable( DALI_ENV_FPS_TRACKING, 0 );
- unsigned int logupdateStatusFrequency = GetIntegerEnvironmentVariable( DALI_ENV_UPDATE_STATUS_INTERVAL, 0 );
- unsigned int logPerformanceLevel = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE, 0 );
- unsigned int logPanGesture = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PAN_GESTURE, 0 );
-
- // all threads here (event, update, and render) will send their logs to SLP Platform's LogMessage handler.
- Dali::Integration::Log::LogFunction logFunction(Dali::SlpPlatform::LogMessage);
-
- mEnvironmentOptions.SetLogOptions( logFunction, logFrameRateFrequency, logupdateStatusFrequency, logPerformanceLevel, logPanGesture );
-
- int predictionMode;
- if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_MODE, predictionMode) )
- {
- mEnvironmentOptions.SetPanGesturePredictionMode(predictionMode);
- }
- int predictionAmount = -1;
- if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT, predictionAmount) )
- {
- if( predictionAmount < 0 )
- {
- // do not support times in the past
- predictionAmount = 0;
- }
- mEnvironmentOptions.SetPanGesturePredictionAmount(predictionAmount);
- }
- int smoothingMode;
- if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_MODE, smoothingMode) )
- {
- mEnvironmentOptions.SetPanGestureSmoothingMode(smoothingMode);
- }
- float smoothingAmount = 1.0f;
- if( GetFloatEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_AMOUNT, smoothingAmount) )
- {
- smoothingAmount = Clamp(smoothingAmount, 0.0f, 1.0f);
- mEnvironmentOptions.SetPanGestureSmoothingAmount(smoothingAmount);
- }
-
- int minimumDistance(-1);
- if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_DISTANCE, minimumDistance ))
- {
- mEnvironmentOptions.SetMinimumPanDistance( minimumDistance );
- }
-
- int minimumEvents(-1);
- if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_EVENTS, minimumEvents ))
- {
- mEnvironmentOptions.SetMinimumPanEvents( minimumEvents );
- }
-
- int glesCallTime(0);
- if ( GetIntegerEnvironmentVariable(DALI_GLES_CALL_TIME, glesCallTime ))
- {
- mEnvironmentOptions.SetGlesCallTime( glesCallTime );
- }
-
- mEnvironmentOptions.InstallLogFunction();
-}
-
-void Adaptor::Initialize()
-{
- ParseEnvironmentOptions();
-
- mPlatformAbstraction = new SlpPlatform::SlpPlatformAbstraction;
-
- if( mEnvironmentOptions.GetPerformanceLoggingLevel() > 0 )
- {
- mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, mEnvironmentOptions );
- }
-
- mCallbackManager = CallbackManager::New();
-
- PositionSize size = mSurface->GetPositionSize();
-
- mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, mEnvironmentOptions);
-
- if( mEnvironmentOptions.GetGlesCallTime() > 0 )
- {
- mGLES = new GlProxyImplementation( mEnvironmentOptions );
- }
- else
- {
- mGLES = new GlImplementation();
- }
-
- mEglFactory = new EglFactory();
-
- EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
-
- mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGLES, *eglSyncImpl, *mGestureManager );
-
- mObjectProfiler = new ObjectProfiler();
-
- mNotificationTrigger = new TriggerEvent( boost::bind(&Adaptor::ProcessCoreEvents, this) );
-
- mVSyncMonitor = new VSyncMonitor;
-
- mUpdateRenderController = new UpdateRenderController( *this, mEnvironmentOptions );
-
- mDaliFeedbackPlugin = new FeedbackPluginProxy( FeedbackPluginProxy::DEFAULT_OBJECT_NAME );
-
- // Should be called after Core creation
- if( mEnvironmentOptions.GetPanGestureLoggingLevel() )
- {
- Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
- }
- if( mEnvironmentOptions.GetPanGesturePredictionMode() >= 0 )
- {
- Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGesturePredictionMode());
- }
- if( mEnvironmentOptions.GetPanGesturePredictionAmount() >= 0.0f )
- {
- Integration::SetPanGesturePredictionAmount(mEnvironmentOptions.GetPanGesturePredictionAmount());
- }
- if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 )
- {
- Integration::SetPanGestureSmoothingMode(mEnvironmentOptions.GetPanGestureSmoothingMode());
- }
- if( mEnvironmentOptions.GetPanGestureSmoothingAmount() >= 0.0f )
- {
- Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions.GetPanGestureSmoothingAmount());
- }
-}
-
-Adaptor::~Adaptor()
-{
- // Ensure stop status
- Stop();
-
- // Release first as we do not want any access to Adaptor as it is being destroyed.
- gThreadLocalAdaptor.release();
-
- for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
- {
- (*iter)->OnDestroy();
- }
-
- delete mUpdateRenderController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
- delete mVSyncMonitor;
- delete mEventHandler;
- delete mObjectProfiler;
-
- delete mCore;
- delete mEglFactory;
- // Delete feedback controller before feedback plugin & style monitor dependencies
- delete mFeedbackController;
- delete mDaliFeedbackPlugin;
- delete mGLES;
- delete mGestureManager;
- delete mPlatformAbstraction;
- delete mCallbackManager;
- delete mPerformanceInterface;
-
- // uninstall it on this thread (main actor thread)
- Dali::Integration::Log::UninstallLogFunction();
-}
-
-void Adaptor::Start()
-{
- // it doesn't support restart after stop at this moment
- // to support restarting, need more testing
- if( READY != mState )
- {
- return;
- }
-
- // Start the callback manager
- mCallbackManager->Start();
-
- // create event handler
- mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
-
- if( mDeferredRotationObserver != NULL )
- {
- mEventHandler->SetRotationObserver(mDeferredRotationObserver);
- mDeferredRotationObserver = NULL;
- }
-
- // guarantee map the surface before starting render-thread.
- mSurface->Map();
-
- // NOTE: dpi must be set before starting the render thread
- // use default or command line settings if not run on device
-#ifdef __arm__
- // set the DPI value for font rendering
- unsigned int dpiHor, dpiVer;
- dpiHor = dpiVer = 0;
- mSurface->GetDpi(dpiHor, dpiVer);
-
- // tell core about the value
- mCore->SetDpi(dpiHor, dpiVer);
-#else
- mCore->SetDpi(mHDpi, mVDpi);
-#endif
-
- // Tell the core the size of the surface just before we start the render-thread
- PositionSize size = mSurface->GetPositionSize();
- mCore->SurfaceResized( size.width, size.height );
-
- // Start the update & render threads
- mUpdateRenderController->Start();
-
- mState = RUNNING;
-
- ProcessCoreEvents(); // Ensure any startup messages are processed.
-
- if ( !mFeedbackController )
- {
- // Start sound & haptic feedback
- mFeedbackController = new FeedbackController( *mDaliFeedbackPlugin );
- }
-
- for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
- {
- (*iter)->OnStart();
- }
-}
-
-// Dali::Internal::Adaptor::Adaptor::Pause
-void Adaptor::Pause()
-{
- // Only pause the adaptor if we're actually running.
- if( RUNNING == mState )
- {
- // Inform observers that we are about to be paused.
- for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
- {
- (*iter)->OnPause();
- }
-
- // Reset the event handler when adaptor paused
- if( mEventHandler )
- {
- mEventHandler->Reset();
- }
-
- mUpdateRenderController->Pause();
- mCore->Suspend();
- mState = PAUSED;
- }
-}
-
-// Dali::Internal::Adaptor::Adaptor::Resume
-void Adaptor::Resume()
-{
- // Only resume the adaptor if we are in the suspended state.
- if( PAUSED == mState )
- {
- mCore->Resume();
- mUpdateRenderController->Resume();
- mState = RUNNING;
-
- // Reset the event handler when adaptor resumed
- if( mEventHandler )
- {
- mEventHandler->Reset();
- }
-
- // Inform observers that we have resumed.
- for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
- {
- (*iter)->OnResume();
- }
-
- ProcessCoreEvents(); // Ensure any outstanding messages are processed
- }
-}
-
-void Adaptor::Stop()
-{
- if( RUNNING == mState ||
- PAUSED == mState ||
- PAUSED_WHILE_HIDDEN == mState )
- {
- for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
- {
- (*iter)->OnStop();
- }
-
- mUpdateRenderController->Stop();
- mCore->Suspend();
-
- // Delete the TTS player
- for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
- {
- if(mTtsPlayers[i])
- {
- mTtsPlayers[i].Reset();
- }
- }
-
- delete mEventHandler;
- mEventHandler = NULL;
-
- delete mNotificationTrigger;
- mNotificationTrigger = NULL;
-
- mCallbackManager->Stop();
-
- mState = STOPPED;
- }
-}
-
-void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
-{
- mEventHandler->FeedTouchPoint( point, timeStamp );
-}
-
-void Adaptor::FeedWheelEvent( MouseWheelEvent& wheelEvent )
-{
- mEventHandler->FeedWheelEvent( wheelEvent );
-}
-
-void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
-{
- mEventHandler->FeedKeyEvent( keyEvent );
-}
-
-bool Adaptor::MoveResize( const PositionSize& positionSize )
-{
- PositionSize old = mSurface->GetPositionSize();
-
- // just resize the surface. The driver should automatically resize the egl Surface (untested)
- // EGL Spec says : EGL window surfaces need to be resized when their corresponding native window
- // is resized. Implementations typically use hooks into the OS and native window
- // system to perform this resizing on demand, transparently to the client.
- mSurface->MoveResize( positionSize );
-
- if(old.width != positionSize.width || old.height != positionSize.height)
- {
- SurfaceSizeChanged(positionSize);
- }
-
- return true;
-}
-
-void Adaptor::SurfaceResized( const PositionSize& positionSize )
-{
- PositionSize old = mSurface->GetPositionSize();
-
- // Called by an application, when it has resized a window outside of Dali.
- // The EGL driver automatically detects X Window resize calls, and resizes
- // the EGL surface for us.
- mSurface->MoveResize( positionSize );
-
- if(old.width != positionSize.width || old.height != positionSize.height)
- {
- SurfaceSizeChanged(positionSize);
- }
-}
-
-void Adaptor::ReplaceSurface( Dali::RenderSurface& surface )
-{
- // adaptor implementation needs the implementation of
- RenderSurface* internalSurface = dynamic_cast<Internal::Adaptor::RenderSurface*>( &surface );
- DALI_ASSERT_ALWAYS( internalSurface && "Incorrect surface" );
-
- mSurface = internalSurface;
-
- SurfaceSizeChanged( internalSurface->GetPositionSize() );
-
- // flush the event queue to give update and render threads chance
- // to start processing messages for new camera setup etc as soon as possible
- ProcessCoreEvents();
-
- // this method is synchronous
- mUpdateRenderController->ReplaceSurface(internalSurface);
-}
-
-void Adaptor::RenderSync()
-{
- mUpdateRenderController->RenderSync();
-}
-
-Dali::RenderSurface& Adaptor::GetSurface() const
-{
- return *mSurface;
-}
-
-Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
-{
- if(!mTtsPlayers[mode])
- {
- // Create the TTS player when it needed, because it can reduce launching time.
- mTtsPlayers[mode] = TtsPlayer::New(mode);
- }
-
- return mTtsPlayers[mode];
-}
-
-bool Adaptor::AddIdle(boost::function<void(void)> callBack)
-{
- bool idleAdded(false);
-
- // Only add an idle if the Adaptor is actually running
- if( RUNNING == mState )
- {
- idleAdded = mCallbackManager->AddCallback(callBack, CallbackManager::IDLE_PRIORITY);
- }
-
- return idleAdded;
-}
-
-bool Adaptor::CallFromMainLoop(boost::function<void(void)> callBack)
-{
- bool callAdded(false);
-
- // Only allow the callback if the Adaptor is actually running
- if ( RUNNING == mState )
- {
- callAdded = mCallbackManager->AddCallback(callBack, CallbackManager::DEFAULT_PRIORITY);
- }
-
- return callAdded;
-}
-
-Dali::Adaptor& Adaptor::Get()
-{
- DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() != NULL && "Adaptor not instantiated" );
- return gThreadLocalAdaptor->mAdaptor;
-}
-
-bool Adaptor::IsAvailable()
-{
- return gThreadLocalAdaptor.get() != NULL;
-}
-
-Dali::Integration::Core& Adaptor::GetCore()
-{
- return *mCore;
-}
-
-void Adaptor::DisableVSync()
-{
- mUpdateRenderController->DisableVSync();
-}
-
-void Adaptor::SetDpi(size_t hDpi, size_t vDpi)
-{
- mHDpi = hDpi;
- mVDpi = vDpi;
-}
-
-EglFactory& Adaptor::GetEGLFactory() const
-{
- DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
- return *mEglFactory;
-}
-
-EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
-{
- return *mEglFactory;
-}
-
-Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
-{
- DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
- return *mGLES;
-}
-
-Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
-{
- return *mPlatformAbstraction;
-}
-
-Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
-{
- return *mGLES;
-}
-
-TriggerEventInterface& Adaptor::GetTriggerEventInterface()
-{
- return *mNotificationTrigger;
-}
-TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
-{
- return mTriggerEventFactory;
-}
-RenderSurface* Adaptor::GetRenderSurfaceInterface()
-{
- return mSurface;
-}
-VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
-{
- return mVSyncMonitor;
-}
-
-KernelTraceInterface& Adaptor::GetKernelTraceInterface()
-{
- return mKernelTracer;
-}
-
-PerformanceInterface* Adaptor::GetPerformanceInterface()
-{
- return mPerformanceInterface;
-}
-
-Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
-{
- DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
- return *mPlatformAbstraction;
-}
-
-void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
-{
- mDragAndDropDetector = detector;
-
- if ( mEventHandler )
- {
- mEventHandler->SetDragAndDropDetector( detector );
- }
-}
-
-void Adaptor::SetRotationObserver( RotationObserver* observer )
-{
- if( mEventHandler )
- {
- mEventHandler->SetRotationObserver( observer );
- }
- else if( mState == READY )
- {
- // Set once event handler exists
- mDeferredRotationObserver = observer;
- }
-}
-
-void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
-{
- if(mTtsPlayers[mode])
- {
- mTtsPlayers[mode].Reset();
- }
-}
-
-void Adaptor::SetMinimumPinchDistance(float distance)
-{
- if( mGestureManager )
- {
- mGestureManager->SetMinimumPinchDistance(distance);
- }
-}
-
-void Adaptor::AddObserver( LifeCycleObserver& observer )
-{
- ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
-
- if ( match == mObservers.end() )
- {
- mObservers.push_back( &observer );
- }
-}
-
-void Adaptor::RemoveObserver( LifeCycleObserver& observer )
-{
- ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
-
- if ( match != mObservers.end() )
- {
- mObservers.erase( match );
- }
-}
-
-void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
-{
- if( mCore )
- {
- mCore->QueueEvent(event);
- }
-}
-
-void Adaptor::ProcessCoreEvents()
-{
- if( mCore )
- {
- if( mPerformanceInterface )
- {
- mPerformanceInterface->AddMarker( PerformanceMarker::PROCESS_EVENTS_START );
- }
-
- mCore->ProcessEvents();
-
- if( mPerformanceInterface )
- {
- mPerformanceInterface->AddMarker( PerformanceMarker::PROCESS_EVENTS_END );
- }
- }
-}
-
-void Adaptor::RequestUpdate()
-{
- // When Dali applications are partially visible behind the lock-screen,
- // the indicator must be updated (therefore allow updates in the PAUSED state)
- if ( PAUSED == mState ||
- RUNNING == mState )
- {
- mUpdateRenderController->RequestUpdate();
- }
-}
-
-void Adaptor::RequestProcessEventsOnIdle()
-{
- // Only request a notification if the Adaptor is actually running
- if ( RUNNING == mState )
- {
- boost::unique_lock<boost::mutex> lock( mIdleInstaller );
-
- // check if the idle handle is already installed
- if( mNotificationOnIdleInstalled )
- {
- return;
- }
- mNotificationOnIdleInstalled = AddIdle( boost::bind( &Adaptor::ProcessCoreEventsFromIdle, this ) );
- }
-}
-
-void Adaptor::OnWindowShown()
-{
- if ( PAUSED_WHILE_HIDDEN == mState )
- {
- // Adaptor can now be resumed
- mState = PAUSED;
-
- Resume();
-
- // Force a render task
- RequestUpdateOnce();
- }
-}
-
-void Adaptor::OnWindowHidden()
-{
- if ( STOPPED != mState )
- {
- Pause();
-
- // Adaptor cannot be resumed until the window is shown
- mState = PAUSED_WHILE_HIDDEN;
- }
-}
-
-// Dali::Internal::Adaptor::Adaptor::OnDamaged
-void Adaptor::OnDamaged( const DamageArea& area )
-{
- // This is needed for the case where Dali window is partially obscured
- RequestUpdate();
-}
-
-void Adaptor::SurfaceSizeChanged(const PositionSize& positionSize)
-{
- // let the core know the surface size has changed
- mCore->SurfaceResized(positionSize.width, positionSize.height);
-
- mResizedSignalV2.Emit( mAdaptor );
-}
-
-void Adaptor::NotifyLanguageChanged()
-{
- mLanguageChangedSignalV2.Emit( mAdaptor );
-}
-
-void Adaptor::RequestUpdateOnce()
-{
- if( PAUSED_WHILE_HIDDEN != mState )
- {
- if( mUpdateRenderController )
- {
- mUpdateRenderController->RequestUpdateOnce();
- }
- }
-}
-
-void Adaptor::ProcessCoreEventsFromIdle()
-{
- ProcessCoreEvents();
-
- // the idle handle automatically un-installs itself
- mNotificationOnIdleInstalled = false;
-}
-
-void Adaptor::RegisterSingleton(const std::type_info& info, BaseHandle singleton)
-{
- if(singleton)
- {
- mSingletonContainer.insert(SingletonPair(info.name(), singleton));
- }
-}
-
-BaseHandle Adaptor::GetSingleton(const std::type_info& info) const
-{
- BaseHandle object = Dali::BaseHandle();
-
- SingletonConstIter iter = mSingletonContainer.find(info.name());
- if(iter != mSingletonContainer.end())
- {
- object = (*iter).second;
- }
-
- return object;
-}
-
-Adaptor::Adaptor(Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout)
-: mAdaptor(adaptor),
- mState(READY),
- mCore(NULL),
- mUpdateRenderController(NULL),
- mVSyncMonitor(NULL),
- mGLES( NULL ),
- mEglFactory( NULL ),
- mSurface( surface ),
- mPlatformAbstraction( NULL ),
- mEventHandler( NULL ),
- mCallbackManager( NULL ),
- mNotificationOnIdleInstalled( false ),
- mNotificationTrigger(NULL),
- mGestureManager(NULL),
- mHDpi( 0 ),
- mVDpi( 0 ),
- mDaliFeedbackPlugin(NULL),
- mFeedbackController(NULL),
- mObservers(),
- mDragAndDropDetector(),
- mDeferredRotationObserver(NULL),
- mBaseLayout(baseLayout),
- mEnvironmentOptions(),
- mPerformanceInterface(NULL),
- mObjectProfiler(NULL)
-{
- DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() == NULL && "Cannot create more than one Adaptor per thread" );
- gThreadLocalAdaptor.reset(this);
-}
-
-// Stereoscopy
-
-void Adaptor::SetViewMode( ViewMode viewMode )
-{
- mSurface->SetViewMode( viewMode );
- mCore->SetViewMode( viewMode );
-}
-
-ViewMode Adaptor::GetViewMode() const
-{
- return mCore->GetViewMode();
-}
-
-void Adaptor::SetStereoBase( float stereoBase )
-{
- mCore->SetStereoBase( stereoBase );
-}
-
-float Adaptor::GetStereoBase() const
-{
- return mCore->GetStereoBase();
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ADAPTOR_IMPL_H__
-#define __DALI_INTERNAL_ADAPTOR_IMPL_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
-#include <boost/function.hpp>
-#include <boost/thread.hpp>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/common/view-mode.h>
-#include <dali/public-api/math/rect.h>
-#include <dali/integration-api/render-controller.h>
-
-#include <dali/public-api/adaptor-framework/common/adaptor.h>
-#include <dali/public-api/adaptor-framework/common/render-surface.h>
-#include <dali/public-api/adaptor-framework/common/tts-player.h>
-#include <dali/public-api/adaptor-framework/common/imf-manager.h>
-#include <dali/public-api/adaptor-framework/common/device-layout.h>
-#include <dali/public-api/adaptor-framework/common/clipboard.h>
-
-#include <slp-platform-abstraction.h>
-#include <base/interfaces/adaptor-internal-services.h>
-#include <base/environment-options.h>
-#include <base/core-event-interface.h>
-#include <internal/common/drag-and-drop-detector-impl.h>
-#include <internal/common/damage-observer.h>
-#include <internal/common/window-visibility-observer.h>
-#include <internal/common/kernel-trace.h>
-#include <internal/common/trigger-event-factory.h>
-
-namespace Dali
-{
-
-namespace Integration
-{
-class Core;
-class GlAbstraction;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-class EventHandler;
-class EglFactory;
-class GestureManager;
-class GlImplementation;
-class GlSyncImplementation;
-class RenderSurface;
-class UpdateRenderController;
-class TriggerEvent;
-class CallbackManager;
-class FeedbackPluginProxy;
-class FeedbackController;
-class RotationObserver;
-class VSyncMonitor;
-class PerformanceInterface;
-class LifeCycleObserver;
-class ObjectProfiler;
-
-/**
- * Implementation of the Adaptor class.
- */
-class Adaptor : public Integration::RenderController,
- public AdaptorInternalServices,
- public CoreEventInterface,
- public DamageObserver,
- public WindowVisibilityObserver
-{
-public:
-
- typedef Dali::Adaptor::AdaptorSignalV2 AdaptorSignalV2;
-
- typedef std::pair<std::string, BaseHandle> SingletonPair;
- typedef std::map<std::string, BaseHandle> SingletonContainer;
- typedef SingletonContainer::const_iterator SingletonConstIter;
-
- /**
- * Creates a New Adaptor
- * @param[in] surface A render surface can be one of the following
- * - Pixmap, adaptor will use existing Pixmap to draw on to
- * - Window, adaptor will use existing Window to draw on to
- * @param[in] baseLayout The base layout that the application has been written for
- */
- DALI_IMPORT_API static Dali::Adaptor* New( RenderSurface* surface, const DeviceLayout& baseLayout );
-
- /**
- * 2-step initialisation, this should be called after creating an adaptor instance.
- */
- void Initialize();
-
- /**
- * Virtual destructor.
- */
- virtual ~Adaptor();
-
- /**
- * @copydoc Dali::Adaptor::Get()
- */
- static Dali::Adaptor& Get();
-
- /**
- * @copydoc Dali::Adaptor::IsAvailable()
- */
- static bool IsAvailable();
-
-public: // AdaptorInternalServices implementation
- /**
- * @copydoc Dali::Adaptor::Start()
- */
- virtual void Start();
-
- /**
- * @copydoc Dali::Adaptor::Pause()
- */
- virtual void Pause();
-
- /**
- * @copydoc Dali::Adaptor::Resume()
- */
- virtual void Resume();
-
- /**
- * @copydoc Dali::Adaptor::Stop()
- */
- virtual void Stop();
-
- /**
- * @copydoc Dali::EventFeeder::FeedTouchPoint()
- */
- virtual void FeedTouchPoint( TouchPoint& point, int timeStamp );
-
- /**
- * @copydoc Dali::EventFeeder::FeedWheelEvent()
- */
- virtual void FeedWheelEvent( MouseWheelEvent& wheelEvent );
-
- /**
- * @copydoc Dali::EventFeeder::FeedKeyEvent()
- */
- virtual void FeedKeyEvent( KeyEvent& keyEvent );
-
- /**
- * @copydoc AdaptorInterface::MoveResize()
- */
- virtual bool MoveResize( const PositionSize& positionSize );
-
- /**
- * @copydoc AdaptorInterface::SurfaceResized()
- */
- virtual void SurfaceResized( const PositionSize& positionSize );
-
- /**
- * @copydoc AdaptorInterface::ReplaceSurface()
- */
- virtual void ReplaceSurface( Dali::RenderSurface& surface );
-
- /**
- * @copydoc AdaptorInterface::RenderSync()
- */
- virtual void RenderSync();
-
- /**
- * @copydoc Dali::Adaptor::GetSurface()
- */
- virtual Dali::RenderSurface& GetSurface() const;
-
- /**
- * Retrieve the TtsPlayer.
- * @param[in] mode The mode of TtsPlayer
- * @return A handle to the TtsPlayer.
- */
- virtual Dali::TtsPlayer GetTtsPlayer(Dali::TtsPlayer::Mode mode);
-
- /**
- * @copydoc Dali::Adaptor::AddIdle()
- */
- virtual bool AddIdle( boost::function<void(void)> callBack );
-
- /**
- * @copydoc Internal::Framework::CallFromMainLoop()
- */
- virtual bool CallFromMainLoop(boost::function<void(void)> callBack);
-
- /**
- * @copydoc Dali::Adaptor::RegisterSingleton()
- */
- virtual void RegisterSingleton(const std::type_info& info, BaseHandle singleton);
-
- /**
- * @copydoc Dali::Adaptor::GetSingleton()
- */
- virtual BaseHandle GetSingleton(const std::type_info& info) const;
-
-public:
-
- /**
- * @return the Core instance
- */
- virtual Dali::Integration::Core& GetCore();
-
- /**
- * Disables GL draw synchronisation with the display.
- */
- DALI_IMPORT_API void DisableVSync();
-
- /**
- * Overrides DPI.
- * Primarily for host/simulation testing
- * @param[in] hDpi The Horizontal DPI
- * @param[in] vDpi The Vertical DPI
- */
- DALI_IMPORT_API void SetDpi(size_t hDpi, size_t vDpi);
-
- /**
- * @return reference to EglFactory class
- */
- EglFactory& GetEGLFactory() const;
-
- /**
- * Return GlAbstraction.
- * @return the GlAbstraction.
- */
- Integration::GlAbstraction& GetGlAbstraction() const;
-
- /**
- * Return the PlatformAbstraction.
- * @return The PlatformAbstraction.
- */
- Integration::PlatformAbstraction& GetPlatformAbstraction() const;
-
- /**
- * Sets the Drag & Drop Listener.
- * @param[in] detector The detector to send Drag & Drop events to.
- */
- void SetDragAndDropDetector( DragAndDropDetectorPtr detector );
-
- /**
- * Sets a rotation observer, or set to NULL to remove.
- * @pre Adaptor::Start() has been called ( to create EventHandler )
- * @param[in] observer The observer to listen for window rotation events
- */
- void SetRotationObserver( RotationObserver* observer );
-
- /**
- * Destroy the TtsPlayer of sepcific mode.
- * @param[in] mode The mode of TtsPlayer to destroy
- */
- void DestroyTtsPlayer(Dali::TtsPlayer::Mode mode);
-
- /**
- * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to
- * trigger a pinch gesture
- *
- * @param[in] distance The minimum pinch distance in pixels
- */
- void SetMinimumPinchDistance(float distance);
-
-public:
-
- /**
- * Adds an adaptor observer so that we can observe the adaptor's lifetime events.
- * @param[in] observer The observer.
- * @note Observers should remove themselves when they are destroyed.
- */
- void AddObserver( LifeCycleObserver& observer );
-
- /**
- * Removes the observer from the adaptor.
- * @param[in] observer The observer to remove.
- * @note Observers should remove themselves when they are destroyed.
- */
- void RemoveObserver( LifeCycleObserver& observer );
-
- /**
- * Emits the Notification event to the Dali core.
- */
- void SendNotificationEvent();
-
- /**
- * Request adaptor to update once
- */
- void RequestUpdateOnce();
-
- /**
- * @copydoc Dali::Adaptor::NotifyLanguageChanged()
- */
- void NotifyLanguageChanged();
-
-public: //AdaptorInternalServices
-
- /**
- * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetPlatformAbstractionInterface()
- */
- virtual Dali::Integration::PlatformAbstraction& GetPlatformAbstractionInterface();
-
- /**
- * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetGlesInterface()
- */
- virtual Dali::Integration::GlAbstraction& GetGlesInterface();
-
- /**
- * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetEGLFactoryInterface()
- */
- virtual EglFactoryInterface& GetEGLFactoryInterface() const;
-
- /**
- * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventInterface()
- */
- virtual TriggerEventInterface& GetTriggerEventInterface();
-
- /**
- * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventFactoryInterface()
- */
- virtual TriggerEventFactoryInterface& GetTriggerEventFactoryInterface();
-
- /**
- * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetRenderSurfaceInterface()
- */
- virtual RenderSurface* GetRenderSurfaceInterface();
-
- /**
- * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetVSyncMonitorInterface()
- */
- virtual VSyncMonitorInterface* GetVSyncMonitorInterface();
-
- /**
- * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetPerformanceInterface()
- */
- virtual PerformanceInterface* GetPerformanceInterface();
-
- /**
- * copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetKernelTraceInterface()
- */
- virtual KernelTraceInterface& GetKernelTraceInterface();
-
-public: // Stereoscopy
-
- /**
- * @copydoc Dali::Integration::Core::SetViewMode()
- */
- DALI_IMPORT_API void SetViewMode( ViewMode viewMode );
-
- /**
- * @copydoc Dali::Integration::Core::GetViewMode()
- */
- DALI_IMPORT_API ViewMode GetViewMode() const;
-
- /**
- * @copydoc Dali::Integration::Core::SetStereoBase()
- */
- DALI_IMPORT_API void SetStereoBase( float stereoBase );
-
- /**
- * @copydoc Dali::Integration::Core::GetStereoBase()
- */
- DALI_IMPORT_API float GetStereoBase() const;
-
-public: // Signals
-
- /**
- * @copydoc Dali::Adaptor::SignalResized
- */
- AdaptorSignalV2& ResizedSignal()
- {
- return mResizedSignalV2;
- }
-
- /**
- * @copydoc Dali::Adaptor::LanguageChangedSignal
- */
- AdaptorSignalV2& LanguageChangedSignal()
- {
- return mLanguageChangedSignalV2;
- }
-
-private: // From Dali::Internal::Adaptor::CoreEventInterface
-
- /**
- * @copydoc Dali::Internal::Adaptor::CoreEventInterface::QueueCoreEvent()
- */
- virtual void QueueCoreEvent(const Dali::Integration::Event& event);
-
- /**
- * @copydoc Dali::Internal::Adaptor:CoreEventInterface:::ProcessCoreEvents()
- */
- virtual void ProcessCoreEvents();
-
-private: // From Dali::Integration::RenderController
-
- /**
- * Called by the Dali core when it requires another update
- */
- virtual void RequestUpdate();
-
- /**
- * Call by the Dali core when it requires an notification event being sent on idle
- */
- virtual void RequestProcessEventsOnIdle();
-
-private: // From Dali::Internal::Adaptor::WindowVisibilityObserver
-
- /**
- * Called when the window becomes fully or partially visible.
- */
- virtual void OnWindowShown();
-
- /**
- * Called when the window is fully hidden.
- */
- virtual void OnWindowHidden();
-
-private: // From Dali::Internal::Adaptor::DamageObserver
-
- /**
- * @copydoc Dali::Internal::Adaptor::DamageObserver::OnDamaged()
- */
- void OnDamaged( const DamageArea& area );
-
-private:
-
- // Undefined
- Adaptor(const Adaptor&);
- Adaptor& operator=(Adaptor&);
-
-private:
-
- /**
- * Helper to parse log options
- */
- void ParseEnvironmentOptions();
-
- /**
- * Informs core the surface size has changed
- */
- void SurfaceSizeChanged(const PositionSize& positionSize);
-
- /**
- * Assigns the render surface to the adaptor
- *
- */
- void SetSurface(Dali::RenderSurface *surface);
-
- /**
- * Sends an notification message from main loop idle handler
- */
- void ProcessCoreEventsFromIdle();
-
-private:
-
- /**
- * Constructor
- * @param[in] adaptor The public adaptor
- * @param[in] surface A render surface can be one of the following
- * - Pixmap, adaptor will use existing Pixmap to draw on to
- * - Window, adaptor will use existing Window to draw on to
- * @param[in] baseLayout The base layout that the application has been written for
- */
- Adaptor( Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout );
-
-private: // Types
-
- enum State
- {
- READY, ///< Initial state before Adaptor::Start is called.
- RUNNING, ///< Adaptor is running.
- PAUSED, ///< Adaptor has been paused.
- PAUSED_WHILE_HIDDEN, ///< Adaptor is paused while window is hidden (& cannot be resumed until window is shown).
- STOPPED, ///< Adaptor has been stopped.
- };
-
- typedef std::vector<LifeCycleObserver*> ObserverContainer;
-
-private: // Data
-
- AdaptorSignalV2 mResizedSignalV2; ///< Resized signal.
- AdaptorSignalV2 mLanguageChangedSignalV2; ///< Language changed signal.
-
- Dali::Adaptor& mAdaptor; ///< Reference to public adaptor instance.
- State mState; ///< Current state of the adaptor
- Dali::Integration::Core* mCore; ///< Dali Core
- UpdateRenderController* mUpdateRenderController; ///< Controls update/render threads
- VSyncMonitor* mVSyncMonitor; ///< Monitors VSync events
- GlImplementation* mGLES; ///< GL implementation
- GlSyncImplementation* mGlSync; ///< GL Sync implementation
- EglFactory* mEglFactory; ///< EGL Factory
-
- RenderSurface* mSurface; ///< Current surface
- SlpPlatform::SlpPlatformAbstraction* mPlatformAbstraction; ///< Platform abstraction
-
- EventHandler* mEventHandler; ///< event handler
- CallbackManager* mCallbackManager; ///< Used to install callbacks
- bool mNotificationOnIdleInstalled; ///< whether the idle handler is installed to send an notification event
- TriggerEvent* mNotificationTrigger; ///< Notification event trigger
- GestureManager* mGestureManager; ///< Gesture manager
- boost::mutex mIdleInstaller; ///< mutex to ensure two threads don't try to install idle handler at the same time
- size_t mHDpi; ///< Override horizontal DPI
- size_t mVDpi; ///< Override vertical DPI
- FeedbackPluginProxy* mDaliFeedbackPlugin; ///< Used to access feedback support
- FeedbackController* mFeedbackController; ///< Plays feedback effects for Dali-Toolkit UI Controls.
- SingletonContainer mSingletonContainer; ///< The container to look up singleton by its type name
- Dali::TtsPlayer mTtsPlayers[Dali::TtsPlayer::MODE_NUM]; ///< Provides TTS support
- ObserverContainer mObservers; ///< A list of adaptor observer pointers
- DragAndDropDetectorPtr mDragAndDropDetector; ///< The Drag & Drop detector
- RotationObserver* mDeferredRotationObserver; ///< deferred Rotation observer needs event handler
- DeviceLayout mBaseLayout; ///< The base layout of the application
- EnvironmentOptions mEnvironmentOptions; ///< environment options
- PerformanceInterface* mPerformanceInterface; ///< Performance interface
- KernelTrace mKernelTracer; ///< Kernel tracer
- TriggerEventFactory mTriggerEventFactory; ///< Trigger event factory
- ObjectProfiler* mObjectProfiler; ///< Tracks object lifetime for profiling
-public:
- inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) {return *adaptor.mImpl;}
-};
-
-} // namespace Internal
-
-} // namespace Adaptor
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ADAPTOR_IMPL_H__
+++ /dev/null
-#ifndef __DALI_CALLBACK_MANAGER_H__
-#define __DALI_CALLBACK_MANAGER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-#include <dali/public-api/common/dali-common.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Abstract interface to install call backs in to an applications main loop.
- */
-class DALI_IMPORT_API CallbackManager
-{
-
-public:
-
- typedef boost::function<void(void)> Callback; ///< Callback typedef
-
- /**
- * Determines the priority of the call back
- */
- enum Priority
- {
- IDLE_PRIORITY, ///< idle priority
- DEFAULT_PRIORITY, ///< priority of the callback will be the same as input handlers and timer callbacks.
- };
-
- /**
- * Controls whether an event once processed by the handler is passed on to other
- * handlers, or not.
- */
- enum EventControl
- {
- CALLBACK_PASS_ON, ///< Pass the event on to any other handlers registered for this event
- CALLBACK_DONE, ///< Don't pass the event to any other handlers
- };
-
- /**
- * Create a new call back interface
- */
- static CallbackManager* New();
-
- /**
- * Virtual destructor
- */
- virtual ~CallbackManager() {}
-
- /**
- * Adds a call back asynchronously.
- * Can be called from any thread.
- * @param callback custom call back function
- * @param priority call back priority
- * @return true on success
- */
- virtual bool AddCallback( Callback callback, Priority priority ) = 0;
-
- /**
- * Adds a call back asynchronously to handle an event.
- * E.g. to handle a CTRL-C event.
- * Can be called from any thread.
- * @param callback custom call back function
- * @return true on success
- */
- virtual bool AddEventCallback( Callback callback, int type, EventControl control ) = 0;
-
- /**
- * Starts the callback manager.
- */
- virtual void Start() = 0;
-
- /**
- * Stop the callback manager and can remove all pending callbacks synchronously.
- * This call will synchronise with the main loop and not return
- * until all call backs have been deleted.
- */
- virtual void Stop() = 0;
-
-protected:
-
- /**
- * constructor
- */
- CallbackManager() {}
-
-private:
-
- // Undefined copy constructor.
- CallbackManager( const CallbackManager& );
-
- // Undefined assignment operator.
- CallbackManager& operator=( const CallbackManager& );
-
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_CALLBACK_MANAGER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "clipboard-event-notifier-impl.h"
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/dali-core.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-BaseHandle Create()
-{
- BaseHandle handle( ClipboardEventNotifier::Get() );
-
- if ( !handle && Adaptor::IsAvailable() )
- {
- Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
- Dali::ClipboardEventNotifier notifier( ClipboardEventNotifier::New() );
- adaptorImpl.RegisterSingleton( typeid( notifier ), notifier );
- handle = notifier;
- }
-
- return handle;
-}
-TypeRegistration CLIPBOARD_EVENT_NOTIFIER_TYPE( typeid(Dali::ClipboardEventNotifier), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
-
-} // unnamed namespace
-
-Dali::ClipboardEventNotifier ClipboardEventNotifier::New()
-{
- Dali::ClipboardEventNotifier notifier = Dali::ClipboardEventNotifier(new ClipboardEventNotifier());
-
- return notifier;
-}
-
-Dali::ClipboardEventNotifier ClipboardEventNotifier::Get()
-{
- Dali::ClipboardEventNotifier notifier;
-
- if ( Adaptor::IsAvailable() )
- {
- // Check whether the singleton is already created
- Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::ClipboardEventNotifier ) );
- if(handle)
- {
- // If so, downcast the handle
- notifier = Dali::ClipboardEventNotifier( dynamic_cast< ClipboardEventNotifier* >( handle.GetObjectPtr() ) );
- }
- }
-
- return notifier;
-}
-
-const std::string& ClipboardEventNotifier::GetContent() const
-{
- return mContent;
-}
-
-void ClipboardEventNotifier::SetContent( const std::string& content )
-{
- mContent = content;
-}
-
-void ClipboardEventNotifier::ClearContent()
-{
- mContent.clear();
-}
-
-void ClipboardEventNotifier::EmitContentSelectedSignal()
-{
- if ( !mContentSelectedSignalV2.Empty() )
- {
- Dali::ClipboardEventNotifier handle( this );
- mContentSelectedSignalV2.Emit( handle );
- }
-}
-
-ClipboardEventNotifier::ClipboardEventNotifier()
-: mContent()
-{
-}
-
-ClipboardEventNotifier::~ClipboardEventNotifier()
-{
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_CLIPBOARD_EVENT_NOTIFIER_H__
-#define __DALI_INTERNAL_CLIPBOARD_EVENT_NOTIFIER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/adaptor-framework/common/clipboard-event-notifier.h>
-
-// INTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * This class listens to Clipboard events.
- */
-class ClipboardEventNotifier : public Dali::BaseObject
-{
-public:
-
- typedef Dali::ClipboardEventNotifier::ClipboardEventSignalV2 ClipboardEventSignalV2;
-
- // Creation
-
- /**
- * Create a ClipboardEventNotifier.
- * @return A newly allocated clipboard-event-notifier.
- */
- static Dali::ClipboardEventNotifier New();
-
- /**
- * @copydoc Dali::ClipboardEventNotifier::Get()
- */
- static Dali::ClipboardEventNotifier Get();
-
- // Public API
-
- /**
- * @copydoc Dali::ClipboardEventNotifier::GetContent() const
- */
- const std::string& GetContent() const;
-
- /**
- * Sets the selected content.
- * @param[in] content A string that represents the content that has been selected.
- */
- void SetContent( const std::string& content );
-
- /**
- * Clears the stored content.
- */
- void ClearContent();
-
- /**
- * Called when content is selected in the clipboard.
- */
- void EmitContentSelectedSignal();
-
-public: // Signals
-
- /**
- * @copydoc Dali::ClipboardEventNotifier::ContentSelectedSignal
- */
- ClipboardEventSignalV2& ContentSelectedSignal()
- {
- return mContentSelectedSignalV2;
- }
-
-private:
-
- // Construction & Destruction
-
- /**
- * Constructor.
- */
- ClipboardEventNotifier();
-
- /**
- * Destructor.
- */
- virtual ~ClipboardEventNotifier();
-
- // Undefined
- ClipboardEventNotifier( const ClipboardEventNotifier& );
- ClipboardEventNotifier& operator=( ClipboardEventNotifier& );
-
-private:
-
- std::string mContent; ///< The current selected content.
-
- ClipboardEventSignalV2 mContentSelectedSignalV2;
-
-public:
-
- // Helpers for public-api forwarding methods
-
- inline static Internal::Adaptor::ClipboardEventNotifier& GetImplementation(Dali::ClipboardEventNotifier& detector)
- {
- DALI_ASSERT_ALWAYS( detector && "ClipboardEventNotifier handle is empty" );
-
- BaseObject& handle = detector.GetBaseObject();
-
- return static_cast<Internal::Adaptor::ClipboardEventNotifier&>(handle);
- }
-
- inline static const Internal::Adaptor::ClipboardEventNotifier& GetImplementation(const Dali::ClipboardEventNotifier& detector)
- {
- DALI_ASSERT_ALWAYS( detector && "ClipboardEventNotifier handle is empty" );
-
- const BaseObject& handle = detector.GetBaseObject();
-
- return static_cast<const Internal::Adaptor::ClipboardEventNotifier&>(handle);
- }
-
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_CLIPBOARD_EVENT_NOTIFIER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "clipboard-impl.h"
-
-// EXTERNAL INCLUDES
-#include <Ecore_X.h>
-#include <dali/public-api/dali-core.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/common/adaptor.h>
-#include <dali/public-api/object/any.h>
-#include <internal/common/adaptor-impl.h>
-#include <internal/common/ecore-x/ecore-x-window-interface.h>
-
-namespace //unnamed namespace
-{
-const char* const CBHM_WINDOW = "CBHM_XWIN";
-const char* const CBHM_MSG = "CBHM_MSG";
-const char* const CBHM_ITEM = "CBHM_ITEM";
-const char* const CBHM_cCOUNT = "CBHM_cCOUNT";
-const char* const CBHM_ERROR = "CBHM_ERROR";
-const char* const SET_ITEM = "SET_ITEM";
-const char* const SHOW = "show0";
-const char* const HIDE = "cbhm_hide";
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Clipboard
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-BaseHandle Create()
-{
- BaseHandle handle( Clipboard::Get() );
-
- if ( !handle && Adaptor::IsAvailable() )
- {
- Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
-
- // The Ecore_X_Window needs to use the Clipboard.
- // Only when the render surface is window, we can get the Ecore_X_Window.
- Ecore_X_Window ecoreXwin( 0 );
- Dali::RenderSurface& surface( adaptorImpl.GetSurface() );
- if( surface.GetType() == Dali::RenderSurface::WINDOW )
- {
- ecoreXwin = AnyCast< Ecore_X_Window >( adaptorImpl.GetSurface().GetSurface() );
- }
-
- // If we fail to get Ecore_X_Window, we can't use the Clipboard correctly.
- // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
- // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
- Dali::Clipboard clipboard = Dali::Clipboard( new Clipboard( ecoreXwin ) );
- adaptorImpl.RegisterSingleton( typeid( clipboard ), clipboard );
- handle = clipboard;
- }
-
- return handle;
-}
-TypeRegistration CLIPBOARD_TYPE( typeid(Dali::Clipboard), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
-
-} // unnamed namespace
-
-Clipboard::Clipboard( Ecore_X_Window ecoreXwin)
-{
- mApplicationWindow = ecoreXwin;
-}
-Clipboard::~Clipboard()
-{
-}
-
-Dali::Clipboard Clipboard::Get()
-{
- Dali::Clipboard clipboard;
-
- if ( Adaptor::IsAvailable() )
- {
- // Check whether the singleton is already created
- Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::Clipboard ) );
- if(handle)
- {
- // If so, downcast the handle
- clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
- }
- }
-
- return clipboard;
-}
-bool Clipboard::SetItem(const std::string &itemData )
-{
- Ecore_X_Window cbhmWin = ECoreX::WindowInterface::GetWindow();
- Ecore_X_Atom atomCbhmItem = ecore_x_atom_get( CBHM_ITEM );
- Ecore_X_Atom dataType = ECORE_X_ATOM_STRING;
-
- // Set item (property) to send
- ecore_x_window_prop_property_set( cbhmWin, atomCbhmItem, dataType, 8, const_cast<char*>( itemData.c_str() ), itemData.length() + 1 );
- ecore_x_sync();
-
- // Trigger sending of item (property)
- Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get( CBHM_MSG );
- ECoreX::WindowInterface::SendXEvent(ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, SET_ITEM );
-
- return true;
-}
-
-/*
- * Get string at given index of clipboard
- */
-std::string Clipboard::GetItem( unsigned int index ) // change string to a Dali::Text object.
-{
- if ( index >= NumberOfItems() )
- {
- return "";
- }
-
- std::string emptyString( "" );
- char sendBuf[20];
-
- snprintf( sendBuf, 20, "%s%d", CBHM_ITEM, index );
- Ecore_X_Atom xAtomCbhmItem = ecore_x_atom_get( sendBuf );
- Ecore_X_Atom xAtomItemType = 0;
-
- std::string clipboardString( ECoreX::WindowInterface::GetWindowProperty(xAtomCbhmItem, &xAtomItemType, index ) );
- if ( !clipboardString.empty() )
- {
- Ecore_X_Atom xAtomCbhmError = ecore_x_atom_get( CBHM_ERROR );
- if ( xAtomItemType != xAtomCbhmError )
- {
- return clipboardString;
- }
- }
-
- return emptyString;
-}
-
-/*
- * Get number of items in clipboard
- */
-unsigned int Clipboard::NumberOfItems()
-{
- Ecore_X_Atom xAtomCbhmCountGet = ecore_x_atom_get( CBHM_cCOUNT );
-
- std::string ret( ECoreX::WindowInterface::GetWindowProperty( xAtomCbhmCountGet, NULL, 0 ) );
-
- int count = -1;
-
- if ( !ret.empty() )
- {
- count = atoi( ret.c_str() );
- }
-
- return count;
-}
-
-/**
- * Show clipboard window
- * Function to send message to show the Clipboard (cbhm) as no direct API available
- * Reference elementary/src/modules/ctxpopup_copypasteUI/cbhm_helper.c
- */
-void Clipboard::ShowClipboard()
-{
- // Claim the ownership of the SECONDARY selection.
- ecore_x_selection_secondary_set(mApplicationWindow, "", 1);
- Ecore_X_Window cbhmWin = ECoreX::WindowInterface::GetWindow();
-
- // Launch the clipboard window
- Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get( CBHM_MSG );
- ECoreX::WindowInterface::SendXEvent( ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, SHOW );
-}
-
-void Clipboard::HideClipboard()
-{
- Ecore_X_Window cbhmWin = ECoreX::WindowInterface::GetWindow();
- // Launch the clipboard window
- Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get( CBHM_MSG );
- ECoreX::WindowInterface::SendXEvent( ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, HIDE );
-
- // release the ownership of SECONDARY selection
- ecore_x_selection_secondary_clear();
-}
-
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_CLIPBOARD_H__
-#define __DALI_INTERNAL_CLIPBOARD_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/common/clipboard.h>
-#include <dali/public-api/object/base-object.h>
-#include <Ecore_X.h>
-
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Implementation of the Clip Board
- */
-
-class Clipboard : public Dali::BaseObject
-{
-public:
-
- /**
- * @copydoc Dali::ClipboardEventNotifier::Get()
- */
- static Dali::Clipboard Get();
-
- /**
- * Constructor
- * @param[in] ecoreXwin, The window is created by application.
- */
-
- Clipboard(Ecore_X_Window ecoreXwin);
- virtual ~Clipboard();
-
- /**
- * @copydoc Dali::Clipboard::SetItem()
- */
- bool SetItem(const std::string &itemData);
-
- /**
- * @copydoc Dali::Clipboard::GetItem()
- */
- std::string GetItem( unsigned int index );
-
- /**
- * @copydoc Dali::Clipboard::NumberOfClipboardItems()
- */
- unsigned int NumberOfItems();
-
- /**
- * @copydoc Dali::Clipboard::ShowClipboard()
- */
- void ShowClipboard();
-
- /**
- * @copydoc Dali::Clipboard::HideClipboard()
- */
- void HideClipboard();
-
-
-private:
- Ecore_X_Window mApplicationWindow;
- Clipboard( const Clipboard& );
- Clipboard& operator=( Clipboard& );
-
-}; // class clipboard
-
-
-} // namespace Adaptor
-
-} // namespace Internal
-
- inline static Internal::Adaptor::Clipboard& GetImplementation(Dali::Clipboard& clipboard)
- {
- DALI_ASSERT_ALWAYS( clipboard && "Clipboard handle is empty" );
- BaseObject& handle = clipboard.GetBaseObject();
- return static_cast<Internal::Adaptor::Clipboard&>(handle);
- }
-
- inline static const Internal::Adaptor::Clipboard& GetImplementation(const Dali::Clipboard& clipboard)
- {
- DALI_ASSERT_ALWAYS( clipboard && "Clipboard handle is empty" );
- const BaseObject& handle = clipboard.GetBaseObject();
- return static_cast<const Internal::Adaptor::Clipboard&>(handle);
- }
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_CLIPBOARD_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "color-controller-impl.h"
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-Dali::ColorController ColorController::Get()
-{
- Dali::ColorController colorController;
- return colorController;
-}
-
-ColorController::ColorController()
-{
-}
-
-ColorController::~ColorController()
-{
-}
-
-bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
-{
- return false;
-}
-
-bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
-{
- return false;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_COLOR_CONTROLLER_H__
-#define __DALI_INTERNAL_COLOR_CONTROLLER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/public-api/object/base-object.h>
-#include <public-api/adaptor-framework/common/color-controller.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Implementation of ColorController
- */
-class ColorController : public BaseObject
-{
-public:
-
- /**
- * Constructor.
- */
- ColorController();
-
- /**
- * @copydoc Dali::ColorController::Get()
- */
- static Dali::ColorController Get();
-
- /**
- * @copydoc Dali::ColorController::RetrieveColor(const std::string&, Vector4&)
- */
- bool RetrieveColor( const std::string& colorCode, Vector4& colorValue );
-
- /**
- *copydoc Dali::ColorController::RetrieveColor(const std::string&, Vector4&, Vector4&, Vector4&)
- */
- bool RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor);
-
-protected:
- /**
- * Destructor.
- */
- virtual ~ColorController();
-
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-// Additional Helpers for public-api forwarding methods
-inline Internal::Adaptor::ColorController& GetImplementation(Dali::ColorController& controller)
-{
- DALI_ASSERT_ALWAYS(controller && "ColorController handle is empty");
- BaseObject& handle = controller.GetBaseObject();
- return static_cast<Internal::Adaptor::ColorController&>(handle);
-}
-
-inline const Internal::Adaptor::ColorController& GetImplementation(const Dali::ColorController& controller)
-{
- DALI_ASSERT_ALWAYS(controller && "ColorController handle is empty");
- const BaseObject& handle = controller.GetBaseObject();
- return static_cast<const Internal::Adaptor::ColorController&>(handle);
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_COLOR_CONTROLLER_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_DAMAGE_OBSERVER_H__
-#define __DALI_INTERNAL_DAMAGE_OBSERVER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-
-#include <dali/public-api/math/rect.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-typedef Rect<int> DamageArea;
-
-/**
- * The DamageObserver can be overridden in order to listen to damage events.
- */
-class DamageObserver
-{
-public:
-
- /**
- * Deriving classes should override this to be notified when we receive a damage event.
- * @param[in] area The area that has been damaged.
- */
- virtual void OnDamaged( const DamageArea& area ) = 0;
-
-protected:
-
- /**
- * Protected Constructor.
- */
- DamageObserver()
- {
- }
-
- /**
- * Protected virtual destructor.
- */
- virtual ~DamageObserver()
- {
- }
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_DAMAGE_OBSERVER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "drag-and-drop-detector-impl.h"
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-Dali::DragAndDropDetector DragAndDropDetector::New()
-{
- Dali::DragAndDropDetector detector = Dali::DragAndDropDetector(new DragAndDropDetector());
-
- return detector;
-}
-
-const std::string& DragAndDropDetector::GetContent() const
-{
- return mContent;
-}
-
-Vector2 DragAndDropDetector::GetCurrentScreenPosition() const
-{
- return mScreenPosition;
-}
-
-bool DragAndDropDetector::IsEnabled() const
-{
- return !mDroppedSignalV2.Empty() || !mEnteredSignalV2.Empty() || !mExitedSignalV2.Empty() || !mMovedSignalV2.Empty() ;
-}
-
-void DragAndDropDetector::SetContent( const std::string& content )
-{
- mContent = content;
-}
-
-void DragAndDropDetector::ClearContent()
-{
- mContent.clear();
-}
-
-void DragAndDropDetector::SetPosition( Vector2 screenPosition )
-{
- mScreenPosition = screenPosition;
-}
-
-void DragAndDropDetector::EmitEnteredSignal()
-{
- if ( !mEnteredSignalV2.Empty() )
- {
- Dali::DragAndDropDetector handle( this );
- mEnteredSignalV2.Emit( handle );
- }
-}
-
-void DragAndDropDetector::EmitExitedSignal()
-{
- if ( !mExitedSignalV2.Empty() )
- {
- Dali::DragAndDropDetector handle( this );
- mExitedSignalV2.Emit( handle );
- }
-}
-
-void DragAndDropDetector::EmitMovedSignal()
-{
- if ( !mMovedSignalV2.Empty() )
- {
- Dali::DragAndDropDetector handle( this );
- mMovedSignalV2.Emit( handle );
- }
-}
-
-void DragAndDropDetector::EmitDroppedSignal()
-{
- if ( !mDroppedSignalV2.Empty() )
- {
- Dali::DragAndDropDetector handle( this );
- mDroppedSignalV2.Emit( handle );
- }
-}
-
-DragAndDropDetector::DragAndDropDetector()
-: mContent(),
- mScreenPosition()
-{
-}
-
-DragAndDropDetector::~DragAndDropDetector()
-{
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__
-#define __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/adaptor-framework/common/drag-and-drop-detector.h>
-
-// INTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-typedef IntrusivePtr< DragAndDropDetector > DragAndDropDetectorPtr;
-
-/**
- * This class listens to Drag & Drop events.
- */
-class DragAndDropDetector : public Dali::BaseObject
-{
-public:
-
- typedef Dali::DragAndDropDetector::DragAndDropSignalV2 DragAndDropSignalV2;
-
- // Creation
-
- /**
- * Create a DragAndDropDetector.
- * This should only be called once by the Window class.
- * @return A newly allocated drag-and-drop-detector.
- */
- static Dali::DragAndDropDetector New();
-
- // Public API
-
- /**
- * @copydoc Dali::DragAndDropDetector::GetContent() const
- */
- const std::string& GetContent() const;
-
- /**
- * @copydoc Dali::DragAndDropDetector::GetCurrentScreenPosition() const
- */
- Vector2 GetCurrentScreenPosition() const;
-
- // Called by Drag & Drop Event Handler
-
- /**
- * Queries whether drag & drop behaviour is really required.
- * @return true if drag & drop required, false otherwise.
- */
- bool IsEnabled() const;
-
- /**
- * Sets the dragged content.
- * @param[in] content A string that represents the content that has been dropped.
- */
- void SetContent( const std::string& content );
-
- /**
- * Clears the stored content.
- */
- void ClearContent();
-
- /**
- * Sets the position the drop occurred.
- */
- void SetPosition( Vector2 screenPosition );
-
- /**
- * Called when a draggable object enters our window.
- */
- void EmitEnteredSignal();
-
- /**
- * Called when a draggable object leaves our window.
- */
- void EmitExitedSignal();
-
- /**
- * Called when a draggable object leaves our window.
- */
- void EmitMovedSignal();
-
- /**
- * Is called when a drop actually occurs.
- */
- void EmitDroppedSignal();
-
-public: // Signals
-
- /**
- * @copydoc Dali::DragAndDropDetector::EnteredSignal
- */
- DragAndDropSignalV2& EnteredSignal()
- {
- return mEnteredSignalV2;
- }
-
- /**
- * @copydoc Dali::DragAndDropDetector::ExitedSignal
- */
- DragAndDropSignalV2& ExitedSignal()
- {
- return mExitedSignalV2;
- }
-
- /**
- * @copydoc Dali::DragAndDropDetector::MovedSignal
- */
- DragAndDropSignalV2& MovedSignal()
- {
- return mMovedSignalV2;
- }
-
- /**
- * @copydoc Dali::DragAndDropDetector::DroppedSignal
- */
- DragAndDropSignalV2& DroppedSignal()
- {
- return mDroppedSignalV2;
- }
-
-private:
-
- // Construction & Destruction
-
- /**
- * Constructor.
- */
- DragAndDropDetector();
-
- /**
- * Destructor.
- */
- virtual ~DragAndDropDetector();
-
- // Undefined
- DragAndDropDetector( const DragAndDropDetector& );
- DragAndDropDetector& operator=( DragAndDropDetector& );
-
-private:
-
- std::string mContent; ///< The current Drag & drop content.
- Vector2 mScreenPosition; ///< The screen position of the drop location.
-
- DragAndDropSignalV2 mEnteredSignalV2;
- DragAndDropSignalV2 mExitedSignalV2;
- DragAndDropSignalV2 mMovedSignalV2;
- DragAndDropSignalV2 mDroppedSignalV2;
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-
-inline Internal::Adaptor::DragAndDropDetector& GetImplementation(Dali::DragAndDropDetector& detector)
-{
- DALI_ASSERT_ALWAYS( detector && "DragAndDropDetector handle is empty" );
-
- BaseObject& handle = detector.GetBaseObject();
-
- return static_cast<Internal::Adaptor::DragAndDropDetector&>(handle);
-}
-
-inline const Internal::Adaptor::DragAndDropDetector& GetImplementation(const Dali::DragAndDropDetector& detector)
-{
- DALI_ASSERT_ALWAYS( detector && "DragAndDropDetector handle is empty" );
-
- const BaseObject& handle = detector.GetBaseObject();
-
- return static_cast<const Internal::Adaptor::DragAndDropDetector&>(handle);
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_DRAG_AND_DROP_DETECTOR_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "ecore-callback-manager.h"
-
-// EXTERNAL INCLUDES
-#include <Ecore.h>
-
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Structure contains the callback function and control options
- */
-struct CallbackData
-{
- /**
- * the type of callback
- */
- enum CallbackType
- {
- STANDARD_CALLBACK, ///< either an idle call back, or a default call back
- EVENT_HANDLER ///< event handler
- };
-
- /**
- * Constructor
- */
- CallbackData(CallbackManager::Callback callback, CallbackType type):
- mCallback(callback),
- mType(type),
- mIdler(NULL),
- mPriority(CallbackManager::DEFAULT_PRIORITY),
- mExecute(true),
- mEventHandler(NULL),
- mEvent(0),
- mEventControl(CallbackManager::CALLBACK_PASS_ON)
- {
- }
-
- // Data
- CallbackManager::Callback mCallback; ///< call back
- CallbackType mType; ///< type of call back
-
- // Data for idle / default call backs
- Ecore_Idler* mIdler; ///< ecore idler
- CallbackManager::Priority mPriority; ///< Priority (idle or normal)
- bool mExecute; ///< whether to run the callback
-
- // Data for event handlers
- Ecore_Event_Handler* mEventHandler; ///< ecore handler
- int mEvent; ///< ecore event id
- CallbackManager::EventControl mEventControl; ///< event control
-
- // function typedef to remove the callbackdata from the callback container
- typedef boost::function<void(CallbackData *)> RemoveFromContainerFunction;
-
- RemoveFromContainerFunction mRemoveFromContainerFunction;
-};
-
-namespace
-{
-
-/**
- * Called from the main thread while idle.
- */
-Eina_Bool IdleCallback(void *data)
-{
- CallbackData *callbackData = static_cast<CallbackData *>(data);
-
- // remove callback data from the container first in case our callback tries to modify the container
- callbackData->mRemoveFromContainerFunction(callbackData);
-
- // run the function
- callbackData->mCallback();
-
- // remove the idle call back
- ecore_idler_del(callbackData->mIdler);
-
- delete callbackData;
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-/**
- * Ecore callback event handler, called from the main thread
- * @param data user data
- * @param type event type, e.g. ECORE_EVENT_SIGNAL_EXIT
- * @param event pointer to ecore event
- */
-Eina_Bool EventHandler(void *data, int type, void *event)
-{
- CallbackData* callbackData = static_cast<CallbackData*>(data);
-
- // make sure the type is for the right event
- DALI_ASSERT_ALWAYS( type == callbackData->mEvent && "Callback data does not match event" );
-
- // remove callback data from the container first in case our callback tries to modify the container
- callbackData->mRemoveFromContainerFunction(callbackData);
-
- // run the call back
- callbackData->mCallback();
-
- Eina_Bool returnVal;
-
- if (callbackData->mEventControl == CallbackManager::CALLBACK_PASS_ON)
- {
- returnVal = ECORE_CALLBACK_PASS_ON;
- }
- else
- {
- returnVal = ECORE_CALLBACK_DONE;
- }
-
- delete callbackData;
-
- return returnVal;
-}
-
-/**
- * called from MainLoopCallback to process standard callbacks
- */
-void AddStandardCallback(CallbackData *callbackData)
-{
- if (callbackData->mPriority == CallbackManager::IDLE_PRIORITY)
- {
- // run the call back on idle
- callbackData->mIdler = ecore_idler_add(IdleCallback, callbackData);
- DALI_ASSERT_ALWAYS( callbackData->mIdler != NULL && "Idle method not created" );
- }
- else
- {
- // run the call back now, then delete it from the container
- if ( callbackData->mExecute )
- {
- callbackData->mCallback();
- }
- callbackData->mRemoveFromContainerFunction(callbackData);
- delete callbackData;
- }
-}
-
-/**
- * called from MainLoopCallback to add event callbacks
- */
-void AddEventCallback(CallbackData *callbackData)
-{
- callbackData->mEventHandler = ecore_event_handler_add(callbackData->mEvent, &EventHandler, callbackData);
-}
-
-/**
- * main loop call back to process call back data.
- */
-void MainLoopCallback(void *data)
-{
- CallbackData *callbackData = static_cast< CallbackData* >(data);
-
- if (callbackData->mType == CallbackData::STANDARD_CALLBACK)
- {
- AddStandardCallback(callbackData);
- }
- else if (callbackData->mType == CallbackData::EVENT_HANDLER)
- {
- AddEventCallback(callbackData);
- }
-}
-
-/**
- * Main loop call back to remove all call back data
- */
-void* MainRemoveAllCallback(void* data)
-{
- EcoreCallbackManager *callbackManager = static_cast<EcoreCallbackManager *>(data);
-
- callbackManager->RemoveAllCallbacksFromMainThread();
-
- return NULL;
-}
-
-} // unnamed namespace
-
-EcoreCallbackManager::EcoreCallbackManager()
-:mRunning(false)
-{
-}
-
-void EcoreCallbackManager::RemoveStandardCallback(CallbackData *callbackData)
-{
- if (callbackData->mPriority == CallbackManager::IDLE_PRIORITY)
- {
- // delete the idle call back
- ecore_idler_del(callbackData->mIdler);
- delete callbackData;
- }
- else
- {
- // ecore doesn't give us a handle for functions we want executing on the
- // main thread, E.g. we can't do
- // handle = ecore_main_loop_thread_safe_call_async( myfunc )
- // ecore_main_loop_thread_remove_async_call(handle); // doesn't exist
- //
- // We just have to set a flag to say do not execute.
- // Hence we can't delete the call back at this point.
- callbackData->mExecute = false;
- }
-}
-
-void EcoreCallbackManager::RemoveEventCallback(CallbackData *callbackData)
-{
- ecore_event_handler_del(callbackData->mEventHandler);
-
- delete callbackData;
-}
-
-void EcoreCallbackManager::Start()
-{
- DALI_ASSERT_DEBUG( mRunning == false );
-
- mRunning = true;
-}
-
-void EcoreCallbackManager::Stop()
-{
- // make sure we're not called twice
- DALI_ASSERT_DEBUG( mRunning == true );
-
- // lock out any other call back functions
- boost::unique_lock< boost::mutex > lock( mMutex );
-
- mRunning = false;
-
- // the synchronous calls return data from the callback, which we ignore.
- ecore_main_loop_thread_safe_call_sync(MainRemoveAllCallback, this);
-}
-
-bool EcoreCallbackManager::AddCallback(Callback callback, Priority priority)
-{
- bool added(false);
-
- if ( mRunning )
- {
- CallbackData *callbackData = new CallbackData(callback, CallbackData::STANDARD_CALLBACK);
-
- callbackData->mPriority = priority;
-
- callbackData->mRemoveFromContainerFunction = boost::bind(&EcoreCallbackManager::RemoveCallbackFromContainer, this,_1);
-
- { // acquire lock to access container
- boost::unique_lock< boost::mutex > lock( mMutex );
-
- // add the call back to the container
- mCallbackContainer.push_front(callbackData);
- }
-
- // Get callbackData processed on the main loop..
-
- ecore_main_loop_thread_safe_call_async(MainLoopCallback, callbackData);
-
- added = true;
- }
-
- return added;
-}
-
-bool EcoreCallbackManager::AddEventCallback(Callback callback, int type, EventControl control)
-{
- bool added(false);
-
- if( mRunning )
- {
- CallbackData *callbackData = new CallbackData(callback,CallbackData::EVENT_HANDLER);
- callbackData->mEventControl = control;
- callbackData->mEvent = type;
-
- callbackData->mRemoveFromContainerFunction = boost::bind(&EcoreCallbackManager::RemoveCallbackFromContainer, this,_1);
-
- { // acquire lock to access container
- boost::unique_lock< boost::mutex > lock( mMutex );
-
- // add the call back to the container
- mCallbackContainer.push_front(callbackData);
- }
-
- // Get callbackData processed on the main loop..
- ecore_main_loop_thread_safe_call_async(MainLoopCallback, callbackData);
-
- added = true;
- }
-
- return added;
-}
-
-void EcoreCallbackManager::RemoveCallbackFromContainer(CallbackData *callbackData)
-{
- // always called from main loop
- boost::unique_lock< boost::mutex > lock( mMutex );
-
- mCallbackContainer.remove(callbackData);
-}
-
-void EcoreCallbackManager::RemoveAllCallbacksFromMainThread()
-{
- // always called from main thread
- // the mutex will already be locked at this point
-
- for( CallbackList::iterator iter = mCallbackContainer.begin(); iter != mCallbackContainer.end(); ++iter)
- {
- CallbackData* data = (*iter);
-
- if (data->mType == CallbackData::STANDARD_CALLBACK)
- {
- RemoveStandardCallback(data);
- }
- else if (data->mType == CallbackData::EVENT_HANDLER)
- {
- RemoveEventCallback(data);
- }
- }
- mCallbackContainer.clear();
-}
-
-// Creates a concrete interface for CallbackManager
-CallbackManager* CallbackManager::New()
-{
- return new EcoreCallbackManager;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_ECORE_CALLBACK_MANAGER_H__
-#define __DALI_ECORE_CALLBACK_MANAGER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <boost/thread.hpp>
-#include <list>
-
-// INTERNAL INCLUDES
-#include <internal/common/callback-manager.h>
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-struct CallbackData;
-
-/**
- * Ecore interface to install call backs in the applications main loop.
- */
-class EcoreCallbackManager : public CallbackManager
-{
-
-public:
-
- /**
- * constructor
- */
- EcoreCallbackManager();
-
- /**
- * destructor
- */
- ~EcoreCallbackManager()
- {
- }
-
- /**
- * @copydoc CallbackManager::AddCallback()
- */
- virtual bool AddCallback(Callback callback, Priority priority);
-
- /**
- * @copydoc CallbackManager::AddEventCallback()
- */
- virtual bool AddEventCallback(Callback callback, int type, EventControl control);
-
- /**
- * @copydoc CallbackManager::Start()
- */
- virtual void Start();
-
- /**
- * @copydoc CallbackManager::Stop()
- */
- virtual void Stop();
-
- /**
- * Remove all call backs
- * Always called from the main thread
- */
- void RemoveAllCallbacksFromMainThread();
-
-private:
-
- /**
- * Deletes any expired callbacks in the callback container
- */
- void RefreshContainer();
-
- /**
- * Removes a single call back from the container
- * Always called from main thread
- * @param callbackData callback data
- */
- void RemoveCallbackFromContainer(CallbackData *callbackData);
-
- /**
- * Remove a standard call back from ecore
- * Always called from main thread
- * @param callbackData callback data
- */
- void RemoveStandardCallback(CallbackData *callbackData);
-
- /**
- * Remove an event handler from ecore
- * Always called from main thread
- * @param callbackData callback data
- */
- void RemoveEventCallback(CallbackData *callbackData);
-
-
-
- typedef std::list<CallbackData *> CallbackList;
-
- bool mRunning; ///< flag is set to true if when running
- CallbackList mCallbackContainer; ///< container of live callbacks
- boost::mutex mMutex; ///< protect access to shared data
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_ECORE_CALLBACK_MANAGER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "pixmap-render-surface.h"
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace ECoreX
-{
-
-DALI_EXPORT_API RenderSurface* CreatePixmapSurface(
- PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent )
-{
- return new PixmapRenderSurface( positionSize, surface, display, name, isTransparent );
-}
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-
-
+++ /dev/null
-#ifndef __DALI_INTERNAL_ADAPTOR_ECORE_X_RENDER_SURFACE_FACTORY_H__
-#define __DALI_INTERNAL_ADAPTOR_ECORE_X_RENDER_SURFACE_FACTORY_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <boost/any.hpp>
-#include <string>
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/common/dali-common.h>
-
-// INTERNAL INCLUDES
-#include <native-buffer-pool.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace ECoreX
-{
-
-class RenderSurface;
-
-/**
- * Surface factory function for pixmap
- * A pixmap surface is created.
- *
- * @param [in] type the type of surface to create
- * @param [in] positionSize the position and size of the surface to create
- * @param [in] display X Pixmap to use, or null for default.
- * @param [in] display X Display to use, or null for default.
- * @param [in] name Name of surface passed in
- * @param [in] isTransparent Whether the surface has an alpha channel
- */
-DALI_IMPORT_API RenderSurface* CreatePixmapSurface(
- PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent );
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ADAPTOR_ECORE_X_RENDER_SURFACE_FACTORY_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "ecore-x-render-surface.h"
-
-// EXTERNAL INCLUDES
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#include <X11/extensions/Xfixes.h> // for damage notify
-#include <X11/extensions/Xdamage.h> // for damage notify
-
-#include <dali/integration-api/gl-abstraction.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/ecore-x/ecore-x-types.h>
-#include <internal/common/trigger-event.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_ECORE_X_RENDER_SURFACE");
-#endif
-
-namespace ECoreX
-{
-
-namespace
-{
-
-const float MINIMUM_DIMENSION_CHANGE = 1.0f; ///< Minimum change for window to be considered to have moved
-static bool gXInitThreadsCalled = false; ///< global to say whether XInitThreads has been called in this process
-const unsigned int MICROSECONDS_PER_SECOND = 1000000;
-const unsigned int MILLISECONDS_PER_SECOND = 1000;
-
-} // unnamed namespace
-
-RenderSurface::RenderSurface( SurfaceType type,
- Dali::PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent)
-: mMainDisplay(NULL),
- mType(type),
- mPosition(positionSize),
- mTitle(name),
- mColorDepth(isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24),
- mRenderMode((type == PIXMAP) ? RENDER_SYNC : RENDER_DEFAULT),
- mRenderNotification( NULL ),
- mSyncMode(SYNC_MODE_NONE),
- mSyncReceived( false ),
- mOwnSurface(false),
- mOwnDisplay(false),
- mIsStopped( false )
-{
- // see if there is a display in Any display
- SetDisplay( display );
-}
-
-void RenderSurface::Init( Any surface )
-{
- // see if there is a surface in Any surface
- unsigned int surfaceId = GetSurfaceId( surface );
-
- // if the surface is empty, create a new one.
- if ( surfaceId == 0 )
- {
- // make sure XInitThreads is called
- if ( !gXInitThreadsCalled )
- {
- XInitThreads();
- gXInitThreadsCalled = true;
- }
-
- // we own the surface about to created
- mOwnSurface = true;
- CreateXRenderable();
- }
- else
- {
- // XLib should already be initialized so no point in calling XInitThreads
- UseExistingRenderable( surfaceId );
- }
-
-#ifdef DEBUG_ENABLED
- // prints out 'INFO: DALI: new RenderSurface, created display xx, used existing surface xx
- // we can not use LOG_INFO because the surface can be created before Dali Core is created.
- printf( "INFO: DALI: new RenderSurface, %s display %p, %s %s surface %X \n",
- mOwnDisplay?"created":"used existing",mMainDisplay,
- mOwnSurface?"created":"used existing",
- Dali::RenderSurface::PIXMAP==mType?" pixmap" :"window",
- GetDrawable() );
-#endif
-}
-
-RenderSurface::~RenderSurface()
-{
- // release the display connection if we use our own
- if( mOwnDisplay )
- {
- if( mMainDisplay )
- {
- // NOTE, on 64bit desktop with some NVidia driver versions this crashes
-#ifdef _ARCH_ARM_
- XCloseDisplay( mMainDisplay );
-#endif
- }
- }
-}
-
-Ecore_X_Window RenderSurface::GetXWindow()
-{
- return 0;
-}
-
-XDisplay* RenderSurface::GetMainDisplay()
-{
- return mMainDisplay;
-}
-
-void RenderSurface::SetRenderNotification( TriggerEvent* renderNotification )
-{
- mRenderNotification = renderNotification;
-}
-
-Ecore_X_Drawable RenderSurface::GetDrawable()
-{
- return 0;
-}
-
-Any RenderSurface::GetDisplay()
-{
- // this getter is used by main thread so we need to return the main thread version of the display
- return Any( ecore_x_display_get() );
-}
-
-PositionSize RenderSurface::GetPositionSize() const
-{
- return mPosition;
-}
-
-void RenderSurface::SetRenderMode(RenderMode mode)
-{
- mRenderMode = mode;
-}
-
-Dali::RenderSurface::RenderMode RenderSurface::GetRenderMode() const
-{
- return mRenderMode;
-}
-
-void RenderSurface::MoveResize( Dali::PositionSize positionSize )
-{
- // nothing to do in base class
-}
-
-void RenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) const
-{
- // calculate DPI
- float xres, yres;
-
- // 1 inch = 25.4 millimeters
- xres = ecore_x_dpi_get();
- yres = ecore_x_dpi_get();
-
- dpiHorizontal = int(xres + 0.5f); // rounding
- dpiVertical = int(yres + 0.5f);
-}
-
-void RenderSurface::Map()
-{
-}
-
-void RenderSurface::TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface )
-{
- // if we don't own the display return
- if( mOwnDisplay == false )
- {
- return;
- }
-
- RenderSurface* other = dynamic_cast< RenderSurface* >( &newSurface );
- if( other )
- {
- // if both surfaces share the same display, and this surface owns it,
- // then transfer the ownership to the new surface
- if( other->mMainDisplay == mMainDisplay )
- {
- mOwnDisplay = false;
- other->mOwnDisplay = true;
- }
- }
-}
-
-void RenderSurface::ConsumeEvents()
-{
- // if the render surface has own display, check events so that we can flush the queue and avoid
- // any potential memory leaks in X
- if( mOwnDisplay )
- {
- // looping if events remain
- int events( 0 );
- do
- {
- // Check if there are any events in the queue
- events = XEventsQueued( mMainDisplay, QueuedAfterFlush );
-
- if ( events > 0 )
- {
- // Just flush event to prevent memory leak from event queue as the events get built up in
- // memory but are only deleted when we retrieve them
- XEvent ev;
- XNextEvent( mMainDisplay, &ev );
- }
- }
- while( events > 0 );
- }
-}
-
-void RenderSurface::StopRender()
-{
- // Stop blocking waiting for sync
- SetSyncMode( RenderSurface::SYNC_MODE_NONE );
- // Simulate a RenderSync in case render-thread is currently blocked
- RenderSync();
-
- mIsStopped = true;
-}
-
-void RenderSurface::SetViewMode( ViewMode )
-{
-}
-
-void RenderSurface::SetDisplay( Any display )
-{
- // the render surface can be passed either EFL e-core types, or x11 types
- // we use boost any to determine at run time which type
-
- if ( display.Empty() == false )
- {
- // check we have a valid type
- DALI_ASSERT_ALWAYS( ( ( display.GetType() == typeid (Ecore_X_Display *)) ||
- ( display.GetType() == typeid (XDisplay *) ) )
- &&
- "Display type is invalid" );
-
- mOwnDisplay = false;
-
- // display may point to EcoreXDisplay so may need to cast
- if( display.GetType() == typeid (Ecore_X_Display*) )
- {
- mMainDisplay = static_cast< XDisplay* >( AnyCast< Ecore_X_Display* >( display ) );
- }
- else
- {
- mMainDisplay = AnyCast< XDisplay* >( display );
- }
- }
- else
- {
- mOwnDisplay = true;
- // mMainDisplay = (XDisplay*)ecore_x_display_get();
- // Because of DDK issue, we need to use separated x display instead of ecore default display
- mMainDisplay = XOpenDisplay(0);
- }
-}
-
-unsigned int RenderSurface::GetSurfaceId( Any surface ) const
-{
- unsigned int surfaceId = 0;
-
- if ( surface.Empty() == false )
- {
- // check we have a valid type
- DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (XWindow) ) ||
- (surface.GetType() == typeid (Ecore_X_Window) ) )
- && "Surface type is invalid" );
-
- if ( surface.GetType() == typeid (Ecore_X_Window) )
- {
- surfaceId = AnyCast<Ecore_X_Window>( surface );
- }
- else
- {
- surfaceId = AnyCast<XWindow>( surface );
- }
- }
- return surfaceId;
-}
-
-void RenderSurface::RenderSync()
-{
- // nothing to do
-}
-
-void RenderSurface::DoRenderSync( unsigned int timeDelta, SyncMode syncMode )
-{
- // Should block waiting for RenderSync?
- if( mRenderMode == Dali::RenderSurface::RENDER_SYNC )
- {
- boost::unique_lock< boost::mutex > lock( mSyncMutex );
-
- // wait for sync
- if( syncMode != SYNC_MODE_NONE &&
- mSyncMode != SYNC_MODE_NONE &&
- !mSyncReceived )
- {
- mSyncNotify.wait( lock );
- }
- mSyncReceived = false;
- }
- // Software sync based on a timed delay?
- else if( mRenderMode > Dali::RenderSurface::RENDER_SYNC )
- {
- unsigned int syncPeriod( MICROSECONDS_PER_SECOND / static_cast< unsigned int >( mRenderMode ) - MILLISECONDS_PER_SECOND );
- if( timeDelta < syncPeriod )
- {
- usleep( syncPeriod - timeDelta );
- }
- }
-}
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H__
-#define __DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-#include <boost/thread.hpp>
-#include <Ecore_X.h>
-#include <dali/public-api/common/dali-common.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/render-surface-impl.h>
-#include <internal/common/ecore-x/ecore-x-types.h>
-#include <internal/common/gl/egl-implementation.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-class TriggerEvent;
-
-namespace ECoreX
-{
-
-/**
- * Ecore X11 implementation of render surface.
- * @todo change namespace to ECore_X11 as the class
- * is no longer pure X11.
- */
-class DALI_IMPORT_API RenderSurface : public Internal::Adaptor::RenderSurface
-{
-public:
- /**
- * Uses an X11 surface to render to.
- * @param [in] type the type of surface passed in
- * @param [in] positionSize the position and size of the surface
- * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
- * @param [in] display connection to X-server if the surface is a X window or pixmap (type must be void * to X display struct)
- * @param [in] name optional name of surface passed in
- * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
- */
- RenderSurface( SurfaceType type,
- Dali::PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent = false);
-
- /**
- * Destructor.
- * Will delete the display, if it has ownership.
- * Will delete the window/pixmap if it has owner ship
- */
- virtual ~RenderSurface();
-
-protected:
- /**
- * Second stage construction
- * Creates the surface (window, pixmap or native buffer)
- */
- void Init( Any surface );
-
-public: // API
-
- /**
- * @return the Ecore X window handle
- */
- Ecore_X_Window GetXWindow();
-
- /**
- * @return the Main X display
- */
- XDisplay* GetMainDisplay();
-
- /**
- * Sets the render notification trigger to call when render thread is completed a frame
- * @param renderNotification to use
- */
- void SetRenderNotification( TriggerEvent* renderNotification );
-
- /**
- * Get the surface as an Ecore_X_drawable
- */
- virtual Ecore_X_Drawable GetDrawable();
-
-public: // from Dali::RenderSurface
-
- /**
- * @copydoc Dali::RenderSurface::GetType()
- */
- virtual Dali::RenderSurface::SurfaceType GetType() = 0;
-
- /**
- * @copydoc Dali::RenderSurface::GetSurface()
- */
- virtual Any GetSurface() = 0;
-
- /**
- * @copydoc Dali::RenderSurface::GetDisplay()
- */
- virtual Any GetDisplay();
-
- /**
- * @copydoc Dali::RenderSurface::GetPositionSize()
- */
- virtual PositionSize GetPositionSize() const;
-
- /**
- * @copydoc Dali::RenderSurface::SetRenderMode()
- */
- virtual void SetRenderMode(RenderMode mode);
-
- /**
- * @copydoc Dali::RenderSurface::GetRenderMode()
- */
- virtual RenderMode GetRenderMode() const;
-
-public: // from Internal::Adaptor::RenderSurface
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface()
- */
- virtual void CreateEglSurface( EglInterface& egl ) = 0;
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface()
- */
- virtual void DestroyEglSurface( EglInterface& egl ) = 0;
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface()
- */
- virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::MoveResize()
- */
- virtual void MoveResize( Dali::PositionSize positionSize);
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::GetDpi()
- */
- virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) const;
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::Map()
- */
- virtual void Map();
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::TransferDisplayOwner()
- */
- virtual void TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::ConsumeEvents()
- */
- virtual void ConsumeEvents();
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::RenderSync()
- */
- virtual void RenderSync();
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::SetViewMode()
- */
- void SetViewMode( ViewMode );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::PreRender()
- */
- virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) = 0;
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::PostRender()
- */
- virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode ) = 0;
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::StopRender()
- */
- virtual void StopRender();
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::SetSyncMode()
- */
- virtual void SetSyncMode( SyncMode syncMode ) { mSyncMode = syncMode; }
-
-private:
-
- /**
- * Sets the display, if display parameter is empty it opens a new display
- * @param display
- */
- void SetDisplay( Any display );
-
- /**
- * Get the surface id if the surface parameter is not empty
- * @param surface Any containing a surface id, or can be empty
- * @return surface id, or zero if surface is empty
- */
- unsigned int GetSurfaceId( Any surface ) const;
-
-protected:
-
- /**
- * Create XRenderable
- */
- virtual void CreateXRenderable() = 0;
-
- /**
- * Use an existing render surface
- * @param surfaceId the id of the surface
- */
- virtual void UseExistingRenderable( unsigned int surfaceId ) = 0;
-
- /**
- * Perform render sync
- * @param[in] currentTime Current time in microseconds
- * @param[in] syncMode Wait for RenderSync (from Adaptor) flag. A member of SyncMode
- */
- void DoRenderSync( unsigned int timeDelta, SyncMode syncMode );
-
-protected: // Data
-
- XDisplay* mMainDisplay; ///< X-connection for rendering
- Ecore_X_Window mRootWindow; ///< X-Root window
- SurfaceType mType; ///< type of renderable
- PositionSize mPosition; ///< Position
- std::string mTitle; ///< Title of window which shows from "xinfo -topvwins" command
- ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
- RenderMode mRenderMode; ///< Render mode for pixmap surface type
- TriggerEvent* mRenderNotification; ///< Render notificatin trigger
- boost::mutex mSyncMutex; ///< mutex to lock during waiting sync
- boost::condition_variable mSyncNotify; ///< condition to notify main thread that pixmap was flushed to onscreen
- SyncMode mSyncMode;
- bool mSyncReceived; ///< true, when a pixmap sync has occurred, (cleared after reading)
- bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
- bool mOwnDisplay; ///< Whether we own the display (responsible for deleting it)
- bool mIsStopped; ///< Render should be stopped
-};
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_X11_TYPES_H__
-#define __DALI_INTERNAL_X11_TYPES_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <X11/Xlib.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-typedef ::Pixmap XPixmap;
-typedef ::Window XWindow;
-typedef ::Display XDisplay;
-typedef ::Screen XScreen;
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif /* __DALI_INTERNAL_X11_TYPES_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "ecore-x-window-interface.h"
-
-// EXTERNAL INCLUDES
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/ecore-x/ecore-x-types.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace ECoreX
-{
-
-namespace WindowInterface
-{
-// CONSTANTS
-const char* const CBHM_WINDOW = "CBHM_XWIN";
-
-Ecore_X_Window GetWindow()
-{
- Ecore_X_Atom xAtomCbhm = ecore_x_atom_get( CBHM_WINDOW );
-
- Ecore_X_Window xCbhmWin = 0;
- unsigned char *buf = NULL;
- int num = 0;
- int ret = ecore_x_window_prop_property_get( 0, xAtomCbhm, XA_WINDOW, 0, &buf, &num );
-
- if ( ret && num )
- {
- memcpy( &xCbhmWin, buf, sizeof( Ecore_X_Window ) );
- }
- if ( buf )
- {
- free( buf );
- }
-
- return xCbhmWin;
-}
-
-std::string GetWindowProperty( Ecore_X_Atom property, Ecore_X_Atom *xDataType, unsigned int num )
-{
- std::string data("");
-
- if ( !property )
- {
- return data;
- }
-
- ecore_x_sync();
-
- long unsigned int numRet = 0, bytes = 0;
- int ret = 0, sizeRet;
- unsigned int i;
- unsigned char *propRet;
- Ecore_X_Atom typeRet;
-
- // X11 Function to get window property
- ret = XGetWindowProperty( static_cast<Display*>(ecore_x_display_get()), // Display* X Server Connection
- GetWindow(), // Window window in question
- property, // Atom name of property
- num, // long offset where required data is stored
- LONG_MAX, // long length of data to retrieve
- False, // Bool flag to delete data
- ecore_x_window_prop_any_type(), // Atom atom id associated to property type
- (Atom *)&typeRet, // Atom actual_type_return, atom id property type
- &sizeRet, // int* format of property
- &numRet, // unsigned long* number of items being returned in prop_return
- &bytes, // unsigned long* remaining bytes if partial retrieval
- &propRet ); // unsigned char** return data
- if ( ret != Success )
- {
- return data;
- }
-
- if ( !numRet )
- {
- XFree( propRet );
- return data;
- }
-
- numRet--; // As propRet in XGetWindowProperty gets an extra 0 added for compatibility reasons.
-
- switch ( sizeRet ) // Format returned by XGetWindowProperty int, short, long
- {
- case 8:
- {
- for ( i = 0; i < numRet; i++ )
- {
- data += propRet[i];
- }
- }
- break;
-
- case 16:
- {
- for ( i = 0; i < numRet; i++ )
- {
- data += ( ( unsigned short * )propRet )[i];
- }
- }
- break;
-
- case 32:
- {
- for ( i = 0; i < numRet; i++ )
- {
- data += ( ( unsigned long * )propRet )[i];
- }
- }
- break;
- }
-
- XFree( propRet );
-
- if ( xDataType )
- {
- *xDataType = typeRet;
- }
-
- return data;
- }
-
-void SendXEvent(Ecore_X_Display* display, Ecore_X_Window window, bool propagate,
- long int eventMask, Ecore_X_Atom messageType, int messageFormat, const char *msg )
-{
- XClientMessageEvent message;
- memset(&message, 0, sizeof( message ) );
- message.type = ClientMessage;
- message.display = static_cast<Display*>( display );
- message.message_type = messageType;
- message.format = messageFormat;
- message.window = window;
- snprintf(message.data.b, 20, "%s", msg);
-
- XSendEvent( static_cast<Display*>( display ), window, propagate, eventMask,( XEvent* )&message );
-}
-
-
-} // namespace WindowInterface
-
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H__
-#define __DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-
-#include <Ecore_X.h>
-#include <X11/Xlib.h>
-
-// INTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace ECoreX
-{
-
-namespace WindowInterface
-{
-/**
- * X11 Window interface, to separate X11 calls within adaptor.
- */
-
-/**
- * Gets the Ecore X Window
- * @return window
- */
- Ecore_X_Window GetWindow();
-
- /**
- * Gets a specified X window property
- * @param[in] property the required property id
- * @param[in] xDataType the type
- * @param[in] num the offset / index of the property
- * @return string the property value
- */
- std::string GetWindowProperty( Ecore_X_Atom property, Ecore_X_Atom *xDataType, unsigned int num );
-
- /**
- * Send an X Event
- * @param[in] display target display
- * @param[in] window target window
- * @param[in] propagate to propagate to other windows
- * @parma[in] eventMask event mask
- * @param[in] messageType Ecore_X_Atom message type
- * @param[in] messageFormat format of message
- * @param[in] msg message to send
- */
- void SendXEvent(Ecore_X_Display* display, Ecore_X_Window window, bool propagate,
- long int eventMask, Ecore_X_Atom messageType, int messageFormat, const char *msg );
-
-} // namespace WindowInterface
-
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "pixmap-render-surface.h"
-
-// EXTERNAL INCLUDES
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#include <X11/extensions/Xfixes.h> // for damage notify
-#include <X11/extensions/Xdamage.h> // for damage notify
-
-#include <dali/integration-api/gl-abstraction.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/ecore-x/ecore-x-types.h>
-#include <internal/common/trigger-event.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-#if defined(DEBUG_ENABLED)
-extern Debug::Filter* gRenderSurfaceLogFilter;
-#endif
-
-namespace ECoreX
-{
-
-PixmapRenderSurface::PixmapRenderSurface( Dali::PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent)
-: RenderSurface( Dali::RenderSurface::PIXMAP, positionSize, surface, display, name, isTransparent )
-{
- Init( surface );
-}
-
-PixmapRenderSurface::~PixmapRenderSurface()
-{
- // release the surface if we own one
- if( mOwnSurface )
- {
- // if we did create the pixmap, delete the pixmap
- DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::General, "Own pixmap (%x) freed\n", mX11Pixmap );
- ecore_x_pixmap_free( mX11Pixmap );
- }
-}
-
-Ecore_X_Drawable PixmapRenderSurface::GetDrawable()
-{
- return (Ecore_X_Drawable)mX11Pixmap;
-}
-
-Dali::RenderSurface::SurfaceType PixmapRenderSurface::GetType()
-{
- return Dali::RenderSurface::PIXMAP;
-}
-
-Any PixmapRenderSurface::GetSurface()
-{
- return Any( mX11Pixmap );
-}
-
-void PixmapRenderSurface::InitializeEgl( EglInterface& eglIf )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
- eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
-
- eglImpl.ChooseConfig(false, mColorDepth);
-}
-
-void PixmapRenderSurface::CreateEglSurface( EglInterface& eglIf )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
-
- // create the EGL surface
- // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
- XPixmap pixmap = static_cast< XPixmap>( mX11Pixmap );
- eglImpl.CreateSurfacePixmap( (EGLNativePixmapType)pixmap, mColorDepth ); // reinterpret_cast does not compile
-}
-
-void PixmapRenderSurface::DestroyEglSurface( EglInterface& eglIf )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
- eglImpl.DestroySurface();
-}
-
-bool PixmapRenderSurface::ReplaceEGLSurface( EglInterface& eglIf )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
- eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
-
- // a new surface for the new pixmap
- // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
- XPixmap pixmap = static_cast< XPixmap>( mX11Pixmap );
- return eglImpl.ReplaceSurfacePixmap( (EGLNativePixmapType)pixmap, // reinterpret_cast does not compile
- reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
-}
-
-bool PixmapRenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& )
-{
- // nothing to do for pixmaps
- return true;
-}
-
-void PixmapRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode )
-{
- // flush gl instruction queue
- glAbstraction.Flush();
-
- // create damage for client applications which wish to know the update timing
- if( mRenderNotification )
- {
- // use notification trigger
- // Tell the event-thread to render the pixmap
- mRenderNotification->Trigger();
- }
- else
- {
- // as a fallback, send damage event. This is needed until livebox is fixed to
- // stop using damage events for render
- Ecore_X_Drawable drawable = GetDrawable();
-
- if( drawable )
- {
- XRectangle rect;
- XserverRegion region;
-
- rect.x = 0;
- rect.y = 0;
- rect.width = mPosition.width;
- rect.height = mPosition.height;
-
- // make a fixes region as updated area
- region = XFixesCreateRegion( mMainDisplay, &rect, 1 );
- // add damage event to updated drawable
- XDamageAdd( mMainDisplay, (Drawable)drawable, region );
- XFixesDestroyRegion( mMainDisplay, region );
-
- XFlush( mMainDisplay );
- }
- }
-
- // Do render synchronisation
- DoRenderSync( timeDelta, syncMode );
-}
-
-void PixmapRenderSurface::CreateXRenderable()
-{
- // check we're creating one with a valid size
- DALI_ASSERT_ALWAYS( mPosition.width > 0 && mPosition.height > 0 && "Pixmap size is invalid" );
-
- // create the pixmap
- mX11Pixmap = ecore_x_pixmap_new(0, mPosition.width, mPosition.height, mColorDepth);
-
- // clear the pixmap
- unsigned int foreground;
- Ecore_X_GC gc;
- foreground = 0;
- gc = ecore_x_gc_new( mX11Pixmap,
- ECORE_X_GC_VALUE_MASK_FOREGROUND,
- &foreground );
- ecore_x_drawable_rectangle_fill( mX11Pixmap, gc, 0, 0, mPosition.width, mPosition.height );
-
- DALI_ASSERT_ALWAYS( mX11Pixmap && "Failed to create X pixmap" );
-
- // we SHOULD guarantee the xpixmap/x11 window was created in x server.
- ecore_x_sync();
-
- ecore_x_gc_free(gc);
-}
-
-void PixmapRenderSurface::UseExistingRenderable( unsigned int surfaceId )
-{
- mX11Pixmap = static_cast< Ecore_X_Pixmap >( surfaceId );
-}
-
-void PixmapRenderSurface::RenderSync()
-{
- {
- boost::unique_lock< boost::mutex > lock( mSyncMutex );
- mSyncReceived = true;
- }
-
- // wake render thread if it was waiting for the notify
- mSyncNotify.notify_all();
-}
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ECORE_X_PIXMAP_RENDER_SURFACE_H__
-#define __DALI_INTERNAL_ECORE_X_PIXMAP_RENDER_SURFACE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <internal/common/ecore-x/ecore-x-render-surface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-class TriggerEvent;
-
-namespace ECoreX
-{
-
-/**
- * Ecore X11 implementation of render surface.
- */
-class PixmapRenderSurface : public RenderSurface
-{
-public:
-
- /**
- * Uses an X11 surface to render to.
- * @param [in] positionSize the position and size of the surface
- * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
- * @param [in] display connection to X-server if the surface is a X window or pixmap (type must be void * to X display struct)
- * @param [in] name optional name of surface passed in
- * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
- */
- PixmapRenderSurface( Dali::PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent = false);
-
- /**
- * @copydoc Dali::Internal::Adaptor::ECoreX::RenderSurface::~RenderSurface
- */
- virtual ~PixmapRenderSurface();
-
-public: // API
-
- /**
- * @copydoc Dali::Internal::Adaptor::ECoreX::RenderSurface::GetDrawable()
- */
- virtual Ecore_X_Drawable GetDrawable();
-
-public: // from Dali::RenderSurface
-
- /**
- * @copydoc Dali::RenderSurface::GetType()
- */
- virtual Dali::RenderSurface::SurfaceType GetType();
-
- /**
- * @copydoc Dali::RenderSurface::GetSurface()
- */
- virtual Any GetSurface();
-
-public: // from Internal::Adaptor::RenderSurface
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::InitializeEgl()
- */
- virtual void InitializeEgl( EglInterface& egl );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface()
- */
- virtual void CreateEglSurface( EglInterface& egl );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface()
- */
- virtual void DestroyEglSurface( EglInterface& egl );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface()
- */
- virtual bool ReplaceEGLSurface( EglInterface& egl );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::RenderSync()
- */
- virtual void RenderSync();
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::PreRender()
- */
- virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::PostRender()
- */
- virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode );
-
-private:
-
- /**
- * Create XPixmap
- */
- virtual void CreateXRenderable();
-
- /**
- * @copydoc Dali::Internal::Adaptor::ECoreX::RenderSurface::UseExistingRenderable
- */
- virtual void UseExistingRenderable( unsigned int surfaceId );
-
-private: // Data
-
- Ecore_X_Pixmap mX11Pixmap; ///< X-Pixmap
-
-};
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ECORE_X_PIXMAP_RENDER_SURFACE_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "window-render-surface.h"
-
-// EXTERNAL INCLUDES
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#include <X11/extensions/Xfixes.h> // for damage notify
-#include <X11/extensions/Xdamage.h> // for damage notify
-
-#include <dali/integration-api/gl-abstraction.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/ecore-x/ecore-x-types.h>
-#include <internal/common/trigger-event.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-#if defined(DEBUG_ENABLED)
-extern Debug::Filter* gRenderSurfaceLogFilter;
-#endif
-
-namespace ECoreX
-{
-
-namespace
-{
-
-const int MINIMUM_DIMENSION_CHANGE( 1 ); ///< Minimum change for window to be considered to have moved
-
-} // unnamed namespace
-
-WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent)
-: RenderSurface( Dali::RenderSurface::WINDOW, positionSize, surface, display, name, isTransparent ),
- mNeedToApproveDeiconify(false)
-{
- DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" );
- Init( surface );
-}
-
-WindowRenderSurface::~WindowRenderSurface()
-{
- if( mOwnSurface )
- {
- ecore_x_window_free( mX11Window );
- }
-}
-
-Ecore_X_Drawable WindowRenderSurface::GetDrawable()
-{
- // already an e-core type
- return (Ecore_X_Drawable)mX11Window;
-}
-
-Dali::RenderSurface::SurfaceType WindowRenderSurface::GetType()
-{
- return Dali::RenderSurface::WINDOW;
-}
-
-Any WindowRenderSurface::GetSurface()
-{
- // already an e-core type
- return Any( mX11Window );
-}
-
-Ecore_X_Window WindowRenderSurface::GetXWindow()
-{
- return mX11Window;
-}
-
-void WindowRenderSurface::RequestToApproveDeiconify()
-{
- mNeedToApproveDeiconify = true;
-}
-
-void WindowRenderSurface::InitializeEgl( EglInterface& eglIf )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
- eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
-
- eglImpl.ChooseConfig(true, mColorDepth);
-}
-
-void WindowRenderSurface::CreateEglSurface( EglInterface& eglIf )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
-
- // create the EGL surface
- // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
- XWindow window = static_cast< XWindow>( mX11Window );
- eglImpl.CreateSurfaceWindow( (EGLNativeWindowType)window, mColorDepth ); // reinterpret_cast does not compile
-}
-
-void WindowRenderSurface::DestroyEglSurface( EglInterface& eglIf )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
- eglImpl.DestroySurface();
-}
-
-bool WindowRenderSurface::ReplaceEGLSurface( EglInterface& eglIf )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- EglImplementation& egl = static_cast<EglImplementation&>( eglIf );
- egl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
-
- // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
- XWindow window = static_cast< XWindow >( mX11Window );
- return egl.ReplaceSurfaceWindow( (EGLNativeWindowType)window, // reinterpret_cast does not compile
- reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
-}
-
-void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize )
-{
- bool needToMove = false;
- bool needToResize = false;
-
- // check moving
- if( (fabs(positionSize.x - mPosition.x) > MINIMUM_DIMENSION_CHANGE) ||
- (fabs(positionSize.y - mPosition.y) > MINIMUM_DIMENSION_CHANGE) )
- {
- needToMove = true;
- }
-
- // check resizing
- if( (fabs(positionSize.width - mPosition.width) > MINIMUM_DIMENSION_CHANGE) ||
- (fabs(positionSize.height - mPosition.height) > MINIMUM_DIMENSION_CHANGE) )
- {
- needToResize = true;
- }
-
- if( needToMove && needToResize)
- {
- ecore_x_window_move_resize(mX11Window, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
- mPosition = positionSize;
- }
- else if(needToMove)
- {
- ecore_x_window_move(mX11Window, positionSize.x, positionSize.y);
- mPosition = positionSize;
- }
- else if (needToResize)
- {
- ecore_x_window_resize(mX11Window, positionSize.width, positionSize.height);
- mPosition = positionSize;
- }
-
-}
-
-void WindowRenderSurface::Map()
-{
- ecore_x_window_show(mX11Window);
-}
-
-bool WindowRenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& )
-{
- // nothing to do for windows
- return true;
-}
-
-void WindowRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int, SyncMode )
-{
- EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );
- eglImpl.SwapBuffers();
-
- // When the window is deiconified, it approves the deiconify operation to window manager after rendering
- if(mNeedToApproveDeiconify)
- {
- // SwapBuffer is desychronized. So make sure to sychronize when window is deiconified.
- glAbstraction.Finish();
-
- /* client sends immediately reply message using value 1 */
- ecore_x_client_message32_send(mX11Window,
- ECORE_X_ATOM_E_DEICONIFY_APPROVE,
- ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
- mX11Window, 1,
- 0, 0, 0);
-
- ecore_x_sync();
-
- mNeedToApproveDeiconify = false;
- }
-}
-
-void WindowRenderSurface::SetViewMode( ViewMode viewMode )
-{
- Ecore_X_Atom viewModeAtom( ecore_x_atom_get( "_E_COMP_3D_APP_WIN" ) );
-
- if( viewModeAtom != None )
- {
- unsigned int value( static_cast<unsigned int>( viewMode ) );
- ecore_x_window_prop_card32_set( mX11Window, viewModeAtom, &value, 1 );
- }
-}
-
-void WindowRenderSurface::CreateXRenderable()
-{
- // if width or height are zero, go full screen.
- if ( (mPosition.width == 0) || (mPosition.height == 0) )
- {
- // Default window size == screen size
- mPosition.x = 0;
- mPosition.y = 0;
-
- ecore_x_screen_size_get( ecore_x_default_screen_get(), &mPosition.width, &mPosition.height );
- }
-
- if(mColorDepth == COLOR_DEPTH_32)
- {
- // create 32 bit window
- mX11Window = ecore_x_window_argb_new( 0, mPosition.x, mPosition.y, mPosition.width, mPosition.height );
- }
- else
- {
- // create 24 bit window
- mX11Window = ecore_x_window_new( 0, mPosition.x, mPosition.y, mPosition.width, mPosition.height );
- }
-
- if ( mX11Window == 0 )
- {
- DALI_ASSERT_ALWAYS(0 && "Failed to create X window");
- }
-
- // set up window title which will be helpful for debug utitilty
- ecore_x_icccm_title_set( mX11Window, mTitle.c_str() );
- ecore_x_netwm_name_set( mX11Window, mTitle.c_str() );
-
- // set up etc properties to match with ecore-evas
- char *id = NULL;
- if( ( id = getenv("DESKTOP_STARTUP_ID") ) )
- {
- ecore_x_netwm_startup_id_set( mX11Window, id );
- }
-
- ecore_x_icccm_hints_set( mX11Window,
- 1, // accepts_focus
- ECORE_X_WINDOW_STATE_HINT_NORMAL, // initial_state
- 0, // icon_pixmap
- 0, // icon_mask
- 0, // icon_window
- 0, // window_group
- 0 ); // is_urgent
-
- // we SHOULD guarantee the x11 window was created in x server.
- ecore_x_sync();
-}
-
-void WindowRenderSurface::UseExistingRenderable( unsigned int surfaceId )
-{
- mX11Window = static_cast< Ecore_X_Window >( surfaceId );
-}
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ECORE_X_WINDOW_RENDER_SURFACE_H__
-#define __DALI_INTERNAL_ECORE_X_WINDOW_RENDER_SURFACE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <internal/common/ecore-x/ecore-x-render-surface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace ECoreX
-{
-
-/**
- * @copydoc Dali::Internal::Adaptor::ECoreX::RenderSurface.
- * Window specialization.
- */
-class WindowRenderSurface : public RenderSurface
-{
-public:
-
- /**
- * Uses an X11 surface to render to.
- * @param [in] positionSize the position and size of the surface
- * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
- * @param [in] display connection to X-server if the surface is a X window or pixmap (type must be void * to X display struct)
- * @param [in] name optional name of surface passed in
- * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
- */
- WindowRenderSurface( Dali::PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent = false );
-
- /**
- * @copydoc Dali::Internal::Adaptor::ECoreX::RenderSurface::~RenderSurface
- */
- virtual ~WindowRenderSurface();
-
-public: // API
-
- /**
- * @copydoc Dali::RenderSurface::GetDrawable()
- */
- virtual Ecore_X_Drawable GetDrawable();
-
- /**
- * Request to approve deiconify operation
- * If it is requested, it will send ECORE_X_ATOM_E_DEICONIFY_APPROVE event to window manager after rendering
- */
- void RequestToApproveDeiconify();
-
-public: // from Dali::RenderSurface
-
- /**
- * @copydoc Dali::RenderSurface::GetType()
- */
- virtual Dali::RenderSurface::SurfaceType GetType();
-
- /**
- * @copydoc Dali::RenderSurface::GetSurface()
- */
- virtual Any GetSurface();
-
- /**
- * @copydoc Dali::RenderSurface::GetDrawable()
- */
- virtual Ecore_X_Window GetXWindow();
-
-public: // from Internal::Adaptor::RenderSurface
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::InitializeEgl()
- */
- virtual void InitializeEgl( EglInterface& egl );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface()
- */
- virtual void CreateEglSurface( EglInterface& egl );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface()
- */
- virtual void DestroyEglSurface( EglInterface& egl );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface()
- */
- virtual bool ReplaceEGLSurface( EglInterface& egl );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::MoveResize()
- */
- virtual void MoveResize( Dali::PositionSize positionSize);
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::Map()
- */
- virtual void Map();
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::PreRender()
- */
- virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::PostRender()
- */
- virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RenderSurface::SetViewMode()
- */
- void SetViewMode( ViewMode viewMode );
-
-protected:
-
- /**
- * Create XWindow
- */
- virtual void CreateXRenderable();
-
- /**
- * @copydoc Dali::Internal::Adaptor::ECoreX::RenderSurface::UseExistingRenderable
- */
- virtual void UseExistingRenderable( unsigned int surfaceId );
-
-private: // Data
-
- Ecore_X_Window mX11Window; ///< X-Window
- bool mNeedToApproveDeiconify; ///< Whether need to send ECORE_X_ATOM_E_DEICONIFY_APPROVE event
-
-}; // class WindowRenderSurface
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ECORE_X_WINDOW_RENDER_SURFACE_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "event-handler.h"
-
-// EXTERNAL INCLUDES
-#include <Ecore.h>
-#include <Ecore_Input.h>
-#include <Ecore_X.h>
-
-#include <cstring>
-
-#include <sys/time.h>
-
-#include <vconf.h>
-#include <vconf-keys.h>
-
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/events/touch-point.h>
-#include <dali/public-api/events/key-event.h>
-#include <dali/public-api/events/mouse-wheel-event.h>
-#include <dali/integration-api/debug.h>
-#include <dali/integration-api/events/key-event-integ.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/mouse-wheel-event-integ.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/events/gesture-manager.h>
-#include <internal/common/ecore-x/window-render-surface.h>
-#include <internal/common/clipboard-impl.h>
-#include <internal/common/key-impl.h>
-#include <internal/common/physical-keyboard-impl.h>
-#include <internal/common/style-monitor-impl.h>
-#include <base/core-event-interface.h>
-
-using namespace std;
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-#if defined(DEBUG_ENABLED)
-namespace
-{
-Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH");
-Integration::Log::Filter* gClientMessageLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_CLIENT_MESSAGE");
-Integration::Log::Filter* gDragAndDropLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DND");
-Integration::Log::Filter* gImfLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_IMF");
-Integration::Log::Filter* gSelectionEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_SELECTION");
-} // unnamed namespace
-#endif
-
-
-namespace
-{
-const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
-
-// Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead.
-size_t Utf8SequenceLength(const unsigned char leadByte)
-{
- size_t length = 0;
-
- if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero)
- {
- length = 1;
- }
- else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
- {
- length = 2;
- }
- else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
- {
- length = 3;
- }
- else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
- {
- length = 4;
- }
- else
- {
- DALI_LOG_WARNING("Unrecognized lead byte %c\n", leadByte);
- }
-
- return length;
-}
-
-const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
-
-const char * CLIPBOARD_ATOM = "CBHM_MSG";
-const char * CLIPBOARD_SET_OWNER_MESSAGE = "SET_OWNER";
-
-/// The atoms required by Ecore for Drag & Drop behaviour.
-Ecore_X_Atom DRAG_AND_DROP_ATOMS[] =
-{
- ECORE_X_ATOM_XDND_ACTION_COPY,
-};
-
-/// The types that we support.
-const char * DRAG_AND_DROP_TYPES[] =
-{
- ECORE_X_SELECTION_TARGET_UTF8_STRING,
-};
-
-const unsigned int DRAG_AND_DROP_ATOMS_NUMBER = sizeof( DRAG_AND_DROP_ATOMS ) / sizeof( Ecore_X_Atom );
-const unsigned int DRAG_AND_DROP_TYPES_NUMBER = sizeof( DRAG_AND_DROP_TYPES ) / sizeof( const char * );
-
-const unsigned int BYTES_PER_CHARACTER_FOR_ATTRIBUTES = 3;
-
-/**
- * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
- * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
- * @param[in] ecoreModifier the Ecore_Event_Modifier input.
- * @return the Ecore_IMF_Keyboard_Modifiers output.
- */
-Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
-{
- int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
-
-
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
- {
- modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
- }
-
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
- {
- modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
- }
-
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
- {
- modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
- }
-
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
- {
- modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
- }
-
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
- {
- modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
- }
-
- return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
-}
-
-
-// Copied from x server
-static unsigned int GetCurrentMilliSeconds(void)
-{
- struct timeval tv;
-
- struct timespec tp;
- static clockid_t clockid;
-
- if (!clockid)
- {
-#ifdef CLOCK_MONOTONIC_COARSE
- if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
- (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
- {
- clockid = CLOCK_MONOTONIC_COARSE;
- }
- else
-#endif
- if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
- {
- clockid = CLOCK_MONOTONIC;
- }
- else
- {
- clockid = ~0L;
- }
- }
- if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
- {
- return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
- }
-
- gettimeofday(&tv, NULL);
- return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
-}
-
-} // unnamed namespace
-
-// Impl to hide EFL implementation.
-struct EventHandler::Impl
-{
- // Construction & Destruction
-
- /**
- * Constructor
- */
- Impl( EventHandler* handler, Ecore_X_Window window )
- : mHandler( handler ),
- mEcoreEventHandler(),
- mWindow( window )
- {
- // Only register for touch and key events if we have a window
- if ( window != 0 )
- {
- // Register Touch events
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, handler ) );
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, handler ) );
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, handler ) );
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_OUT, EcoreEventMouseButtonUp, handler ) ); // process mouse out event like up event
-
- // Register Mouse wheel events
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, handler ) );
-
- // Register Key events
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, handler ) );
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, handler ) );
-
- // Register Focus events
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_FOCUS_IN, EcoreEventWindowFocusIn, handler ) );
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_FOCUS_OUT, EcoreEventWindowFocusOut, handler ) );
-
- // Register Window damage events
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_DAMAGE, EcoreEventWindowDamaged, handler ) );
-
- // Enable Drag & Drop and register DnD events
- ecore_x_dnd_aware_set( window, EINA_TRUE );
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_ENTER, EcoreEventDndEnter, handler) );
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_POSITION, EcoreEventDndPosition, handler) );
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_LEAVE, EcoreEventDndLeave, handler) );
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_DROP, EcoreEventDndDrop, handler) );
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_FINISHED, EcoreEventDndFinished, handler) );
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_STATUS, EcoreEventDndStatus, handler) );
-
- // Register Client message events - accessibility etc.
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_CLIENT_MESSAGE, EcoreEventClientMessage, handler ) );
-
- // Register Selection event - clipboard selection, Drag & Drop selection etc.
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_SELECTION_CLEAR, EcoreEventSelectionClear, handler ) );
- mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_SELECTION_NOTIFY, EcoreEventSelectionNotify, handler ) );
-
- // Register Vconf notify - font name, font size and style
- vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, handler );
- vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, handler );
-#if defined(DALI_PROFILE_MOBILE)
- vconf_notify_key_changed( VCONFKEY_SETAPPL_CHANGE_UI_THEME_INT, VconfNotifyThemeChanged, handler );
-#endif
- }
- }
-
- /**
- * Destructor
- */
- ~Impl()
- {
-#if defined(DALI_PROFILE_MOBILE)
- vconf_ignore_key_changed( VCONFKEY_SETAPPL_CHANGE_UI_THEME_INT, VconfNotifyThemeChanged );
-#endif
- vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
- vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
-
- for( std::vector<Ecore_Event_Handler*>::iterator iter = mEcoreEventHandler.begin(), endIter = mEcoreEventHandler.end(); iter != endIter; ++iter )
- {
- ecore_event_handler_del( *iter );
- }
- }
-
- // Static methods
-
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // Touch Callbacks
- /////////////////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Called when a touch down is received.
- */
- static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
- {
- Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
- EventHandler* handler( (EventHandler*)data );
-
- if ( touchEvent->window == handler->mImpl->mWindow )
- {
- TouchPoint::State state ( TouchPoint::Down );
-
- // Check if the buttons field is set and ensure it's the primary touch button.
- // If this event was triggered by buttons other than the primary button (used for touch), then
- // just send an interrupted event to Core.
- if ( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
- {
- state = TouchPoint::Interrupted;
- }
-
- TouchPoint point( touchEvent->multi.device, state, touchEvent->x, touchEvent->y );
- handler->SendEvent( point, touchEvent->timestamp );
- }
-
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when a touch up is received.
- */
- static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
- {
- Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
- EventHandler* handler( (EventHandler*)data );
-
- if ( touchEvent->window == handler->mImpl->mWindow )
- {
- TouchPoint point( touchEvent->multi.device, TouchPoint::Up, touchEvent->x, touchEvent->y );
- handler->SendEvent( point, touchEvent->timestamp );
- }
-
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when a touch up is received.
- */
- static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
- {
- Ecore_Event_Mouse_Wheel *mouseWheelEvent( (Ecore_Event_Mouse_Wheel*)event );
-
- DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT Ecore_Event_Mouse_Wheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z);
-
- EventHandler* handler( (EventHandler*)data );
- if ( mouseWheelEvent->window == handler->mImpl->mWindow )
- {
- MouseWheelEvent wheelEvent(mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
- handler->SendMouseWheelEvent( wheelEvent );
- }
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when a touch motion is received.
- */
- static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
- {
- Ecore_Event_Mouse_Move *touchEvent( (Ecore_Event_Mouse_Move*)event );
- EventHandler* handler( (EventHandler*)data );
-
- if ( touchEvent->window == handler->mImpl->mWindow )
- {
- TouchPoint point( touchEvent->multi.device, TouchPoint::Motion, touchEvent->x, touchEvent->y );
- handler->SendEvent( point, touchEvent->timestamp );
- }
-
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // Key Callbacks
- /////////////////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Called when a key down is received.
- */
- static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
- {
- DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyDown \n" );
-
- EventHandler* handler( (EventHandler*)data );
- Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
- bool eventHandled( false );
-
- Ecore_IMF_Context* imfContext = NULL;
- if ( Dali::Adaptor::IsAvailable() && handler->mImfManager )
- {
- imfContext = reinterpret_cast<Ecore_IMF_Context*>( handler->mImfManager.GetContext() );
- }
-
- // If a device key then skip ecore_imf_context_filter_event.
- if ( imfContext && !( KeyLookup::IsDeviceButton( keyEvent->keyname ) ) )
- {
- // We're consuming key down event so we have to pass to IMF so that it can parse it as well.
- Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
- ecoreKeyDownEvent.keyname = keyEvent->keyname;
- ecoreKeyDownEvent.key = keyEvent->key;
- ecoreKeyDownEvent.string = keyEvent->string;
- ecoreKeyDownEvent.compose = keyEvent->compose;
- ecoreKeyDownEvent.timestamp = keyEvent->timestamp;
- ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
- ecoreKeyDownEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
-
- eventHandled = ecore_imf_context_filter_event( imfContext,
- ECORE_IMF_EVENT_KEY_DOWN,
- (Ecore_IMF_Event *) &ecoreKeyDownEvent );
-
- // If the event has not been handled by IMF then check if we should reset our IMF context
- if( !eventHandled )
- {
- if ( !strcmp( keyEvent->keyname, "Escape" ) ||
- !strcmp( keyEvent->keyname, "Return" ) ||
- !strcmp( keyEvent->keyname, "KP_Enter" ) )
- {
- ecore_imf_context_reset( imfContext );
- }
- }
- }
-
- // If the event wasn't handled then we should send a key event.
- if ( !eventHandled )
- {
- if ( keyEvent->window == handler->mImpl->mWindow )
- {
- std::string keyName( keyEvent->keyname );
- std::string keyString( "" );
- int keyCode = ecore_x_keysym_keycode_get(keyEvent->keyname);
- int modifier( keyEvent->modifiers );
- unsigned long time = keyEvent->timestamp;
-
- // Ensure key event string is not NULL as keys like SHIFT have a null string.
- if ( keyEvent->string )
- {
- keyString = keyEvent->string;
- }
-
- KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, KeyEvent::Down);
- handler->SendEvent( keyEvent );
- }
- }
-
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when a key up is received.
- */
- static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
- {
- DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyUp \n" );
-
- EventHandler* handler( (EventHandler*)data );
- Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
- bool eventHandled( false );
-
- Ecore_IMF_Context* imfContext = NULL;
- if ( Dali::Adaptor::IsAvailable() && handler->mImfManager )
- {
- imfContext = reinterpret_cast<Ecore_IMF_Context*>( handler->mImfManager.GetContext() );
- }
-
- // XF86Stop and XF86Send must skip ecore_imf_context_filter_event.
- if ( imfContext && strcmp( keyEvent->keyname, "XF86Send" ) && strcmp( keyEvent->keyname, "XF86Phone" ) && strcmp( keyEvent->keyname, "XF86Stop" ) )
-
- {
- // We're consuming key up event so we have to pass to IMF so that it can parse it as well.
- Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
- ecoreKeyUpEvent.keyname = keyEvent->keyname;
- ecoreKeyUpEvent.key = keyEvent->key;
- ecoreKeyUpEvent.string = keyEvent->string;
- ecoreKeyUpEvent.compose = keyEvent->compose;
- ecoreKeyUpEvent.timestamp = keyEvent->timestamp;
- ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
- ecoreKeyUpEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
-
- eventHandled = ecore_imf_context_filter_event( imfContext,
- ECORE_IMF_EVENT_KEY_UP,
- (Ecore_IMF_Event *) &ecoreKeyUpEvent );
- }
-
- // If the event wasn't handled then we should send a key event.
- if ( !eventHandled )
- {
- if ( keyEvent->window == handler->mImpl->mWindow )
- {
- std::string keyName( keyEvent->keyname );
- std::string keyString( "" );
- int keyCode = ecore_x_keysym_keycode_get(keyEvent->keyname);
- int modifier( keyEvent->modifiers );
- unsigned long time( keyEvent->timestamp );
-
- // Ensure key event string is not NULL as keys like SHIFT have a null string.
- if ( keyEvent->string )
- {
- keyString = keyEvent->string;
- }
-
- KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, KeyEvent::Up);
- handler->SendEvent( keyEvent );
-
- }
- }
-
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // Window Callbacks
- /////////////////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Called when the window gains focus.
- */
- static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
- {
- Ecore_X_Event_Window_Focus_In* focusInEvent( (Ecore_X_Event_Window_Focus_In*)event );
- EventHandler* handler( (EventHandler*)data );
-
- DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusIn \n" );
-
- // If the window gains focus and we hid the keyboard then show it again.
- if ( focusInEvent->win == handler->mImpl->mWindow )
- {
- DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventWindowFocusIn - >>WindowFocusGained \n" );
-
- if ( handler->mImfManager )
- {
- ImfManager& imfManager( ImfManager::GetImplementation( handler->mImfManager ) );
- if( imfManager.RestoreAfterFocusLost() )
- {
- imfManager.Activate();
- }
- }
- // No need to connect callbacks as KeyboardStatusChanged will be called.
- }
-
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when the window loses focus.
- */
- static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
- {
- Ecore_X_Event_Window_Focus_Out* focusOutEvent( (Ecore_X_Event_Window_Focus_Out*)event );
- EventHandler* handler( (EventHandler*)data );
-
- DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusOut \n" );
-
- // If the window loses focus then hide the keyboard.
- if ( focusOutEvent->win == handler->mImpl->mWindow )
- {
- if ( handler->mImfManager )
- {
- ImfManager& imfManager( ImfManager::GetImplementation( handler->mImfManager ) );
- if( imfManager.RestoreAfterFocusLost() )
- {
- imfManager.Deactivate();
- }
- }
-
- // Clipboard don't support that whether clipboard is shown or not. Hide clipboard.
- Dali::Clipboard clipboard = Clipboard::Get();
- clipboard.HideClipboard();
- }
-
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when the window is damaged.
- */
- static Eina_Bool EcoreEventWindowDamaged(void *data, int type, void *event)
- {
- Ecore_X_Event_Window_Damage* windowDamagedEvent( (Ecore_X_Event_Window_Damage*)event );
- EventHandler* handler( (EventHandler*)data );
-
- if( windowDamagedEvent->win == handler->mImpl->mWindow )
- {
- DamageArea area;
- area.x = windowDamagedEvent->x;
- area.y = windowDamagedEvent->y;
- area.width = windowDamagedEvent->w;
- area.height = windowDamagedEvent->h;
-
- handler->SendEvent( area );
- }
-
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when the window properties are changed.
- * We are only interested in the font change.
- */
-
-
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // Drag & Drop Callbacks
- /////////////////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Called when a dragged item enters our window's bounds.
- * This is when items are dragged INTO our window.
- */
- static Eina_Bool EcoreEventDndEnter( void* data, int type, void* event )
- {
- DALI_LOG_INFO( gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndEnter\n" );
-
- Ecore_X_Event_Xdnd_Enter* enterEvent( (Ecore_X_Event_Xdnd_Enter*) event );
- EventHandler* handler( (EventHandler*)data );
- Ecore_X_Window window ( handler->mImpl->mWindow );
-
- if ( enterEvent->win == window )
- {
- DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
-
- // Check whether the Drag & Drop detector has Drag & Drop behaviour enabled before we accept.
- if ( dndDetector && dndDetector->IsEnabled() )
- {
- // Tell Ecore that we want to enable drop in the entire window.
- Ecore_X_Rectangle rect;
- rect.x = rect.y = 0;
- ecore_x_window_geometry_get( window, NULL, NULL, (int*)&rect.width, (int*)&rect.height );
-
- // Tell Ecore that we are able to process a drop.
- ecore_x_dnd_send_status( EINA_TRUE, EINA_FALSE, rect, ECORE_X_ATOM_XDND_DROP );
-
- // Register the required atoms and types.
- ecore_x_dnd_actions_set( window, DRAG_AND_DROP_ATOMS, DRAG_AND_DROP_ATOMS_NUMBER );
- ecore_x_dnd_types_set( window, DRAG_AND_DROP_TYPES, DRAG_AND_DROP_TYPES_NUMBER );
-
- // Request to get the content from Ecore.
- ecore_x_selection_xdnd_request( window, ECORE_X_SELECTION_TARGET_UTF8_STRING );
-
- DALI_LOG_INFO( gDragAndDropLogFilter, Debug::General, "EcoreEventDndEnter: Requesting Drag & Drop\n" );
-
- // Clear the previous content
- dndDetector->ClearContent();
-
- // Emit the entered signal
- dndDetector->EmitEnteredSignal();
- }
- }
-
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when a dragged item is moved within our window.
- * This is when items are dragged INTO our window.
- */
- static Eina_Bool EcoreEventDndPosition( void* data, int type, void* event )
- {
- DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndPosition\n" );
-
- Ecore_X_Event_Xdnd_Position* positionEvent( (Ecore_X_Event_Xdnd_Position*) event );
- EventHandler* handler( (EventHandler*)data );
-
- if ( positionEvent->win == handler->mImpl->mWindow )
- {
- DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
-
- // If we have a detector then update its latest position.
- if ( dndDetector )
- {
- DALI_LOG_INFO(gDragAndDropLogFilter, Debug::General, "EcoreEventDndPosition: position ( %d x %d )\n", positionEvent->position.x, positionEvent->position.y );
- dndDetector->SetPosition( Vector2( positionEvent->position.x, positionEvent->position.y ));
- dndDetector->EmitMovedSignal();
- }
- }
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when a dragged item leaves our window's bounds.
- * This is when items are dragged INTO our window.
- */
- static Eina_Bool EcoreEventDndLeave( void* data, int type, void* event )
- {
- DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndLeave\n" );
-
- Ecore_X_Event_Xdnd_Leave* leaveEvent( (Ecore_X_Event_Xdnd_Leave*) event );
- EventHandler* handler( (EventHandler*)data );
-
- if ( leaveEvent->win == handler->mImpl->mWindow )
- {
- DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
-
- // If we have a detector then clear its content and emit the exited-signal. Also tell Ecore that we have finished.
- if ( dndDetector )
- {
- dndDetector->ClearContent();
- dndDetector->EmitExitedSignal();
-
- ecore_x_dnd_send_finished();
-
- DALI_LOG_INFO( gDragAndDropLogFilter, Debug::General, "EcoreEventDndLeave: Finished\n" );
- }
- }
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when the dragged item is dropped within our window's bounds.
- * This is when items are dragged INTO our window.
- */
- static Eina_Bool EcoreEventDndDrop( void* data, int type, void* event )
- {
- DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndDrop\n" );
-
- Ecore_X_Event_Xdnd_Drop* dropEvent ( (Ecore_X_Event_Xdnd_Drop*) event);
- EventHandler* handler( (EventHandler*)data );
-
- if ( dropEvent->win == handler->mImpl->mWindow )
- {
- DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
-
- // Something has been dropped, inform the detector (if we have one) and tell Ecore that we have finished.
- if ( dndDetector )
- {
- DALI_LOG_INFO(gDragAndDropLogFilter, Debug::General, "EcoreEventDndDrop: position ( %d x %d )\n", dropEvent->position.x, dropEvent->position.y );
-
- dndDetector->SetPosition( Vector2( dropEvent->position.x, dropEvent->position.y ) );
- dndDetector->EmitDroppedSignal();
- ecore_x_dnd_send_finished();
-
- DALI_LOG_INFO( gDragAndDropLogFilter, Debug::General, "EcoreEventDndDrop: Finished\n" );
- }
- }
-
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when a dragged item is moved from our window and the target window has done processing it.
- * This is when items are dragged FROM our window.
- */
- static Eina_Bool EcoreEventDndFinished( void* data, int type, void* event )
- {
- DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndFinished\n" );
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when a dragged item is moved from our window and the target window has sent us a status.
- * This is when items are dragged FROM our window.
- */
- static Eina_Bool EcoreEventDndStatus( void* data, int type, void* event )
- {
- DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndStatus\n" );
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when the client messages (i.e. the accessibility events) are received.
- */
- static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
- {
- Ecore_X_Event_Client_Message* clientMessageEvent( (Ecore_X_Event_Client_Message*)event );
- EventHandler* handler( (EventHandler*)data );
-
- if (clientMessageEvent->message_type == ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL)
- {
- if ( ( (unsigned int)clientMessageEvent->data.l[0] == handler->mImpl->mWindow ) && handler->mAccessibilityManager )
- {
- AccessibilityManager* accessibilityManager( &AccessibilityManager::GetImplementation( handler->mAccessibilityManager ) );
-
- if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_SCROLL)
- {
- // 2 finger touch & move, 2 finger flick
-
- // mouse state : e->data.l[2] (0: mouse down, 1: mouse move, 2: mouse up)
- // x : e->data.l[3]
- // y : e->data.l[4]
- TouchPoint::State state(TouchPoint::Down);
-
- if ((unsigned int)clientMessageEvent->data.l[2] == 0)
- {
- state = TouchPoint::Down; // mouse down
- }
- else if ((unsigned int)clientMessageEvent->data.l[2] == 1)
- {
- state = TouchPoint::Motion; // mouse move
- }
- else if ((unsigned int)clientMessageEvent->data.l[2] == 2)
- {
- state = TouchPoint::Up; // mouse up
- }
- else
- {
- state = TouchPoint::Interrupted; // error
- }
-
- DALI_LOG_INFO(gClientMessageLogFilter, Debug::General,
- "[%s:%d] [%d] %d, %d\n", __FUNCTION__, __LINE__,
- (unsigned int)clientMessageEvent->data.l[2],
- (unsigned int)clientMessageEvent->data.l[3], (unsigned int)clientMessageEvent->data.l[4]);
-
- // Send touch event to accessibility manager.
- TouchPoint point( 0, state, (float)clientMessageEvent->data.l[3], (float)clientMessageEvent->data.l[4] );
-
- // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
- accessibilityManager->HandleActionScrollEvent( point, GetCurrentMilliSeconds() );
- }
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_MOUSE)
- {
- // 1 finger double tap and hold
-
- // mouse state : e->data.l[2] (0: mouse down, 1: mouse move, 2: mouse up)
- // x : e->data.l[3]
- // y : e->data.l[4]
- TouchPoint::State state(TouchPoint::Down);
-
- if ((unsigned int)clientMessageEvent->data.l[2] == 0)
- {
- state = TouchPoint::Down; // mouse down
- }
- else if ((unsigned int)clientMessageEvent->data.l[2] == 1)
- {
- state = TouchPoint::Motion; // mouse move
- }
- else if ((unsigned int)clientMessageEvent->data.l[2] == 2)
- {
- state = TouchPoint::Up; // mouse up
- }
- else
- {
- state = TouchPoint::Interrupted; // error
- }
-
- DALI_LOG_INFO(gClientMessageLogFilter, Debug::General,
- "[%s:%d] [%d] %d, %d\n", __FUNCTION__, __LINE__,
- (unsigned int)clientMessageEvent->data.l[2],
- (unsigned int)clientMessageEvent->data.l[3], (unsigned int)clientMessageEvent->data.l[4]);
-
- // Send touch event to accessibility manager.
- TouchPoint point( 0, state, (float)clientMessageEvent->data.l[3], (float)clientMessageEvent->data.l[4] );
-
- // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
- accessibilityManager->HandleActionTouchEvent( point, GetCurrentMilliSeconds() );
- }
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_BACK)
- {
- // 2 finger circle draw, do back
- accessibilityManager->HandleActionBackEvent();
- }
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_NEXT)
- {
- // one finger flick down
- // focus next object
- if(accessibilityManager)
- {
- accessibilityManager->HandleActionNextEvent();
- }
- }
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_PREV)
- {
- // one finger flick up
- // focus previous object
- if(accessibilityManager)
- {
- accessibilityManager->HandleActionPreviousEvent();
- }
- }
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE)
- {
- // one finger double tap
- // same as one finger tap in normal mode (i.e. execute focused actor)
- if(accessibilityManager)
- {
- accessibilityManager->HandleActionActivateEvent();
- }
- }
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ)
- {
- // one finger tap
- // focus & read an actor at ( e->data.l[2], e->data.l[3] ) position according to finger
- if(accessibilityManager)
- {
- accessibilityManager->HandleActionReadEvent((unsigned int)clientMessageEvent->data.l[2], (unsigned int)clientMessageEvent->data.l[3], true /* allow read again*/);
- }
- }
-#if defined(DALI_PROFILE_MOBILE) || defined(DALI_PROFILE_TV)
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_OVER)
- {
- // one finger tap & move
- // mouse state : e->data.l[2] (0: mouse down, 1: mouse move, 2: mouse up)
- // x : e->data.l[3]
- // y : e->data.l[4]
- // focus & read an actor at (x, y) position according to finger
- if(accessibilityManager && (unsigned int)clientMessageEvent->data.l[2] == 1 /*only work for move event*/)
- {
- accessibilityManager->HandleActionReadEvent((unsigned int)clientMessageEvent->data.l[3], (unsigned int)clientMessageEvent->data.l[4], false /* not allow read again*/);
- }
- }
-#endif
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_NEXT)
- {
- // one finger flick right
- // focus next object
- if(accessibilityManager)
- {
- accessibilityManager->HandleActionReadNextEvent();
- }
- }
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_PREV)
- {
- // one finger flick left
- // focus previous object
- if(accessibilityManager)
- {
- accessibilityManager->HandleActionReadPreviousEvent();
- }
- }
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_UP)
- {
- // double down and move (right, up)
- // change slider value
- if(accessibilityManager)
- {
- accessibilityManager->HandleActionUpEvent();
- }
- }
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DOWN)
- {
- // double down and move (left, down)
- // change slider value
- if(accessibilityManager)
- {
- accessibilityManager->HandleActionDownEvent();
- }
- }
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ENABLE)
- {
- if(accessibilityManager)
- {
- accessibilityManager->HandleActionEnableEvent();
- }
- }
- else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DISABLE)
- {
- if(accessibilityManager)
- {
- accessibilityManager->HandleActionDisableEvent();
- }
- }
- // TODO: some more actions could be added later
- }
- }
- else if(clientMessageEvent->message_type == ecore_x_atom_get(CLIPBOARD_ATOM))
- {
- std::string message(clientMessageEvent->data.b);
- if( message == CLIPBOARD_SET_OWNER_MESSAGE)
- {
- // Claim the ownership of the SECONDARY selection.
- ecore_x_selection_secondary_set(handler->mImpl->mWindow, "", 1);
-
- // Show the clipboard window
- Dali::Clipboard clipboard = Dali::Clipboard::Get();
- clipboard.ShowClipboard();
- }
- }
- else if( clientMessageEvent->message_type == ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_PREPARE )
- {
- RotationEvent rotationEvent;
- rotationEvent.angle = static_cast<int>(clientMessageEvent->data.l[1]);
- rotationEvent.winResize = static_cast<int>(clientMessageEvent->data.l[2]);
- rotationEvent.width = static_cast<int>(clientMessageEvent->data.l[3]);
- rotationEvent.height = static_cast<int>(clientMessageEvent->data.l[4]);
- handler->SendRotationPrepareEvent( rotationEvent );
- }
- else if( clientMessageEvent->message_type == ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST )
- {
- handler->SendRotationRequestEvent();
- }
-
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when the source window notifies us the content in clipboard is selected.
- */
- static Eina_Bool EcoreEventSelectionClear( void* data, int type, void* event )
- {
- DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionClear\n" );
- Ecore_X_Event_Selection_Clear* selectionClearEvent( (Ecore_X_Event_Selection_Clear*) event );
- EventHandler* handler( (EventHandler*)data );
-
- if ( selectionClearEvent->win == handler->mImpl->mWindow )
- {
- if ( selectionClearEvent->selection == ECORE_X_SELECTION_SECONDARY )
- {
- // Request to get the content from Ecore.
- ecore_x_selection_secondary_request(selectionClearEvent->win, ECORE_X_SELECTION_TARGET_TEXT);
- }
- }
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /**
- * Called when the source window sends us about the selected content.
- * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
- */
- static Eina_Bool EcoreEventSelectionNotify( void* data, int type, void* event )
- {
- DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionNotify\n" );
-
- Ecore_X_Event_Selection_Notify* selectionNotifyEvent( (Ecore_X_Event_Selection_Notify*) event );
- EventHandler* handler( (EventHandler*)data );
-
- if ( selectionNotifyEvent->win == handler->mImpl->mWindow )
- {
- Ecore_X_Selection_Data* selectionData( (Ecore_X_Selection_Data*) selectionNotifyEvent->data );
- if ( selectionData->data )
- {
- if ( selectionNotifyEvent->selection == ECORE_X_SELECTION_XDND )
- {
- DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
-
- // We have got the content that is to be dropped, inform the DndListener (if we have one).
- if ( dndDetector )
- {
- std::string content( (char*) selectionData->data, selectionData->length );
- dndDetector->SetContent( content );
-
- DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "EcoreEventSelectionNotify: Content(%d):\n" , selectionData->length );
- DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "======================================\n" );
- DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "%s\n", selectionData->data );
- DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "======================================\n" );
- }
- }
- else if ( selectionNotifyEvent->selection == ECORE_X_SELECTION_SECONDARY )
- {
- // We have got the selected content, inform the clipboard event listener (if we have one).
- if ( handler->mClipboardEventNotifier )
- {
- ClipboardEventNotifier& clipboardEventNotifier( ClipboardEventNotifier::GetImplementation( handler->mClipboardEventNotifier ) );
- std::string content( (char*) selectionData->data, selectionData->length );
- clipboardEventNotifier.SetContent( content );
- clipboardEventNotifier.EmitContentSelectedSignal();
- }
-
- // Claim the ownership of the SECONDARY selection.
- ecore_x_selection_secondary_set(handler->mImpl->mWindow, "", 1);
-
- DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "EcoreEventSelectionNotify: Content(%d):\n" , selectionData->length );
- DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "======================================\n" );
- DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "%s\n", selectionData->data );
- DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "======================================\n" );
- }
- }
- }
- return ECORE_CALLBACK_PASS_ON;
- }
-
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // Font Callbacks
- /////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- * Called when a font name is changed.
- */
- static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
- {
- EventHandler* handler = static_cast<EventHandler*>( data );
-
- StyleChange fontChange;
- fontChange.defaultFontChange = true;
-
- handler->SendEvent( fontChange );
- }
-
- /**
- * Called when a font size is changed.
- */
- static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
- {
- EventHandler* handler = static_cast<EventHandler*>( data );
-
- StyleChange fontChange;
- fontChange.defaultFontSizeChange = true;
-
- handler->SendEvent( fontChange );
- }
-
- /**
- * Called when style is changed
- */
- static void VconfNotifyThemeChanged( keynode_t* node, void* data )
- {
- EventHandler* handler( static_cast<EventHandler*>(data) );
-
- StyleChange themeChange;
- themeChange.themeChange = true;
-
- handler->SendEvent( themeChange );
- }
-
- // Data
- EventHandler* mHandler;
- std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
- Ecore_X_Window mWindow;
-};
-
-EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
-: mCoreEventInterface(coreEventInterface),
- mGestureManager( gestureManager ),
- mStyleMonitor( StyleMonitor::Get() ),
- mDamageObserver( damageObserver ),
- mRotationObserver( NULL ),
- mDragAndDropDetector( dndDetector ),
- mAccessibilityManager( AccessibilityManager::Get() ),
- mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
- mClipboard(Clipboard::Get()),
- mImfManager( ImfManager::Get() ),
- mImpl( NULL )
-{
- Ecore_X_Window window = 0;
-
- if( surface->GetType() == Dali::RenderSurface::WINDOW )
- {
- // this code only works with the EcoreX11 RenderSurface so need to downcast
- ECoreX::WindowRenderSurface* ecoreSurface = dynamic_cast< ECoreX::WindowRenderSurface* >( surface );
- if( ecoreSurface )
- {
- // enable multi touch
- window = ecoreSurface->GetXWindow();
- ecore_x_input_multi_select( window );
- }
- }
-
- mImpl = new Impl(this, window);
-}
-
-EventHandler::~EventHandler()
-{
- if(mImpl)
- {
- delete mImpl;
- }
-
- mGestureManager.Stop();
-}
-
-void EventHandler::SendEvent(TouchPoint& point, unsigned long timeStamp)
-{
- if(timeStamp < 1)
- {
- timeStamp = GetCurrentMilliSeconds();
- }
-
- Integration::TouchEvent event;
- if (mCombiner.GetNextTouchEvent(point, timeStamp, event))
- {
- DALI_LOG_INFO(gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.deviceId, point.state, point.local.x, point.local.y);
-
- // First the touch event & related gesture events are queued
- mCoreEventInterface.QueueCoreEvent( event );
- mGestureManager.SendEvent(event);
-
- // Next the events are processed with a single call into Core
- mCoreEventInterface.ProcessCoreEvents();
- }
-}
-
-void EventHandler::SendEvent(KeyEvent& keyEvent)
-{
- Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
- if ( physicalKeyboard )
- {
- if ( ! KeyLookup::IsDeviceButton( keyEvent.keyPressedName.c_str() ) )
- {
- GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
- }
- }
-
- // Create KeyEvent and send to Core.
- Integration::KeyEvent event(keyEvent.keyPressedName, keyEvent.keyPressed, keyEvent.keyCode,
- keyEvent.keyModifier, keyEvent.time, static_cast<Integration::KeyEvent::State>(keyEvent.state));
- mCoreEventInterface.QueueCoreEvent( event );
- mCoreEventInterface.ProcessCoreEvents();
-}
-
-void EventHandler::SendMouseWheelEvent( MouseWheelEvent& wheelEvent )
-{
- // Create MouseWheelEvent and send to Core.
- Integration::MouseWheelEvent event(wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp);
- mCoreEventInterface.QueueCoreEvent( event );
- mCoreEventInterface.ProcessCoreEvents();
-}
-
-void EventHandler::SendEvent(StyleChange styleChange)
-{
- DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
- GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
-}
-
-void EventHandler::SendEvent( const DamageArea& area )
-{
- mDamageObserver.OnDamaged( area );
-}
-
-void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
-{
- if( mRotationObserver != NULL )
- {
- mRotationObserver->OnRotationPrepare( event );
- }
-}
-
-void EventHandler::SendRotationRequestEvent( )
-{
- if( mRotationObserver != NULL )
- {
- mRotationObserver->OnRotationRequest( );
- }
-}
-
-void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
-{
- SendEvent(point, timeStamp);
-}
-
-void EventHandler::FeedWheelEvent( MouseWheelEvent& wheelEvent )
-{
- SendMouseWheelEvent( wheelEvent );
-}
-
-void EventHandler::FeedKeyEvent( KeyEvent& event )
-{
- SendEvent( event );
-}
-
-void EventHandler::FeedEvent( Integration::Event& event )
-{
- mCoreEventInterface.QueueCoreEvent( event );
- mCoreEventInterface.ProcessCoreEvents();
-}
-
-void EventHandler::Reset()
-{
- mCombiner.Reset();
-
- // Any touch listeners should be told of the interruption.
- Integration::TouchEvent event;
- TouchPoint point(0, TouchPoint::Interrupted, 0, 0);
- event.AddPoint( point );
-
- // First the touch event & related gesture events are queued
- mCoreEventInterface.QueueCoreEvent( event );
- mGestureManager.SendEvent( event );
-
- // Next the events are processed with a single call into Core
- mCoreEventInterface.ProcessCoreEvents();
-}
-
-void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
-{
- mDragAndDropDetector = detector;
-}
-
-void EventHandler::SetRotationObserver( RotationObserver* observer )
-{
- mRotationObserver = observer;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_EVENT_HANDLER_H__
-#define __DALI_INTERNAL_EVENT_HANDLER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/events/touch-event-combiner.h>
-#include <dali/public-api/adaptor-framework/common/style-monitor.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/damage-observer.h>
-#include <internal/common/drag-and-drop-detector-impl.h>
-#include <internal/common/accessibility-manager-impl.h>
-#include <internal/common/clipboard-event-notifier-impl.h>
-#include <internal/common/imf-manager-impl.h>
-#include <internal/common/rotation-observer.h>
-
-namespace Dali
-{
-
-struct StyleChange;
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class CoreEventInterface;
-class GestureManager;
-class RenderSurface;
-class StyleMonitor;
-
-/**
- * The Event Handler class is responsible for setting up receiving of Ecore events and then converts them
- * to TouchEvents when it does receive them.
- *
- * These TouchEvents are then passed on to Core.
- */
-class EventHandler
-{
-public:
-
- /**
- * Constructor.
- * @param[in] surface The surface where events will be sent to.
- * @param[in] coreEventInterface Used to send events to Core.
- * @param[in] gestureManager The Gesture Manager.
- * @param[in] damageObserver The damage observer (to pass damage events to).
- * @param[in] dndDetector The Drag & Drop listener (to pass DnD events to).
- */
- EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector );
-
- /**
- * Destructor.
- */
- ~EventHandler();
-
- /**
- * Feed (Send) touch event to core and gesture manager
- * @param[in] touchEvent The touch event holding the touch point information.
- */
- void FeedTouchPoint( TouchPoint& point, int timeStamp );
-
- /**
- * Feed (Send) mouse wheel event to core and gesture manager
- * @param[in] wheelEvent The mouse wheel event
- */
- void FeedWheelEvent( MouseWheelEvent& wheelEvent );
-
- /**
- * Feed (Send) key event to core
- * @param[in] keyEvent The key event holding the key information.
- */
- void FeedKeyEvent( KeyEvent& keyEvent );
-
- /**
- * Feed (Send) an event to core
- * @param[in] event The event information.
- */
- void FeedEvent( Integration::Event& event );
-
- /**
- * Resets the event handler.
- */
- void Reset();
-
- /**
- * Sets the Drag & Drop detector.
- * @param[in] detector An intrusive pointer to the Drag & Drop listener to set. To unset pass in NULL.
- */
- void SetDragAndDropDetector( DragAndDropDetectorPtr detector );
-
- /**
- * Set the rotation observer (note, some adaptors may not have a rotation observer)
- * @param[in] observer The rotation observer
- */
- void SetRotationObserver( RotationObserver* observer );
-
-private:
-
- /**
- * Send touch event to core.
- * @param[in] point The touch point information.
- * @param[in] timeStamp The time the touch occurred.
- */
- void SendEvent(TouchPoint& point, unsigned long timeStamp);
-
- /**
- * Send key event to core.
- * @param[in] keyEvent The KeyEvent to send.
- */
- void SendEvent(KeyEvent& keyEvent);
-
- /**
- * Send mouse wheel event to core.
- * @param[in] wheelEvent The mouse wheel event
- */
- void SendMouseWheelEvent( MouseWheelEvent& wheelEvent );
-
- /**
- * Send a style change event to the style monitor.
- * @param[in] styleChange The style that has changed.
- */
- void SendEvent(StyleChange styleChange);
-
- /**
- * Send a window damage event to the observer.
- * @param[in] area Damaged area.
- */
- void SendEvent( const DamageArea& area );
-
- /**
- * Inform rotation observer of rotation prepare event
- * @param[in] rotation The rotation event
- */
- void SendRotationPrepareEvent( const RotationEvent& rotation );
-
- /**
- * Inform rotation observer of rotation prepare event
- */
- void SendRotationRequestEvent( );
-
-private:
-
- CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
- Dali::Integration::TouchEventCombiner mCombiner; ///< Combines multi-touch events.
- GestureManager& mGestureManager; ///< Reference to the GestureManager, set on construction, to send touch events to for analysis.
- Dali::StyleMonitor mStyleMonitor; ///< Handle to the style monitor, set on construction, to send font size and font change events to.
- DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to.
- RotationObserver* mRotationObserver; ///< Pointer to rotation observer, if present.
-
- DragAndDropDetectorPtr mDragAndDropDetector; ///< Pointer to the drag & drop detector, to send Drag & Drop events to.
- Dali::AccessibilityManager mAccessibilityManager; ///< Pointer to the accessibility manager
- Dali::ClipboardEventNotifier mClipboardEventNotifier; ///< Pointer to the clipboard event notifier
- Dali::Clipboard mClipboard;///< Pointer to the clipboard
- Dali::ImfManager mImfManager; ///< Pointer to the IMF manager.
-
- struct Impl; ///< Contains Ecore specific information
- Impl* mImpl; ///< Created on construction and destroyed on destruction.
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_EVENT_HANDLER_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_GESTURE_DETECTOR_H__
-#define __DALI_INTERNAL_GESTURE_DETECTOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/events/gesture.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/object/ref-object.h>
-
-namespace Dali
-{
-
-namespace Integration
-{
-class Core;
-class GestureRequest;
-struct TouchEvent;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Abstract Base class for all adaptor gesture detectors.
- *
- * @note this may be replaced by gesture events sent directly from X.
- */
-class GestureDetector : public RefObject
-{
-public:
-
- /**
- * Called by the gesture manager when it gets a touch event. The gesture detector should
- * evaluate this event along with previously received events to determine whether the gesture
- * they require has taken place.
- * @param[in] event The latest touch event.
- */
- virtual void SendEvent(const Integration::TouchEvent& event) = 0;
-
- /**
- * Called by the gesture manager when Core updates the gesture's detection requirements.
- * @param[in] request The updated detection requirements.
- */
- virtual void Update(const Integration::GestureRequest& request) = 0;
-
- /**
- * Returns the type of gesture detector.
- * @return Type of gesture detector.
- */
- Gesture::Type GetType() const { return mType; }
-
-protected:
-
- /**
- * Protected Constructor. Should only be able to create derived class objects.
- * @param[in] screenSize The size of the screen.
- * @param[in] detectorType The type of gesture detector.
- */
- GestureDetector(Vector2 screenSize, Gesture::Type detectorType)
- : mScreenSize(screenSize), mType(detectorType) {}
-
- /**
- * Virtual destructor.
- */
- virtual ~GestureDetector() {}
-
-protected:
-
- Vector2 mScreenSize;
- Gesture::Type mType;
-};
-
-typedef IntrusivePtr<GestureDetector> GestureDetectorPtr;
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_GESTURE_DETECTOR_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "gesture-manager.h"
-
-// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
-
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/events/gesture-detector.h>
-#include <internal/common/events/long-press-gesture-detector.h>
-#include <internal/common/events/pan-gesture-detector.h>
-#include <internal/common/events/pinch-gesture-detector.h>
-#include <internal/common/events/tap-gesture-detector.h>
-#include <base/core-event-interface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-
-#if defined(DEBUG_ENABLED)
-Integration::Log::Filter* gLogFilter = Integration::Log::Filter::New( Debug::NoLogging, false, "LOG_GESTURE_MANAGER" );
-
-/**
- * Helper method to return the string representation of a gesture type.
- */
-const char * GetGestureTypeString( Gesture::Type type )
-{
- static const char * const pinch( "Pinch" );
- static const char * const pan( "Pan" );
- static const char * const tap( "tap" );
- static const char * const longPress( "LongPress" );
- static const char * const invalid( "Invalid" );
-
- const char * retVal( NULL );
-
- switch ( type )
- {
- case Gesture::LongPress:
- {
- retVal = longPress;
- break;
- }
-
- case Gesture::Pan:
- {
- retVal = pan;
- break;
- }
-
- case Gesture::Pinch:
- {
- retVal = pinch;
- break;
- }
-
- case Gesture::Tap:
- {
- retVal = tap;
- break;
- }
-
- default:
- retVal = invalid;
- break;
- }
-
- return retVal;
-};
-#endif // DEBUG_ENABLED
-
-const float MINIMUM_DISTANCE_DELTA_DIVISOR = 85.0f;
-} // unnamed namespace
-
-GestureManager::GestureManager(CoreEventInterface& coreEventInterface, Vector2 screenSize,CallbackManager* callbackManager, EnvironmentOptions& environmentOptions)
-: mCoreEventInterface( coreEventInterface ),
- mScreenSize( screenSize ),
- mCallbackManager( callbackManager ),
- mEnvironmentOptions( environmentOptions ),
- mMinimumDistanceDelta(-1.0f),
- mRunning( true ) // This allows gestures to be created before Adaptor::Start() is called e.g. by Indicator
-{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Creating GestureManager\n" );
-}
-
-GestureManager::~GestureManager()
-{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Destroying GestureManager\n" );
-}
-
-void GestureManager::SendEvent(const Integration::TouchEvent& event)
-{
- if (mRunning)
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SendEvent: START\n" );
-
- // gestures can be added / deleted during SendEvent so we make a copy of the container.
- // the gestures are reference counted, so unused gesture detectors will be deleted when
- // the local variable detectors goes out of scope.
- GestureDetectorContainer detectors( mGestureDetectors );
-
- // Send the event to all gesture detectors.
- for ( GestureDetectorContainer::iterator iter = detectors.begin(), endIter = detectors.end(); iter != endIter; ++iter )
- {
- (*iter)->SendEvent(event);
- }
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SendEvent: END\n" );
- }
-}
-
-void GestureManager::Stop()
-{
- if (mRunning)
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Stop\n" );
-
- mGestureDetectors.clear();
- mRunning = false;
- }
-}
-
-void GestureManager::SetMinimumPinchDistance(float distance)
-{
- mMinimumDistanceDelta = distance;
- for( GestureDetectorContainer::iterator iter = mGestureDetectors.begin(), endIter = mGestureDetectors.end(); iter != endIter; ++iter )
- {
- if ( ( *iter )->GetType() == Gesture::Pinch )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "Set Minimum Pinch Distance: %f\n", distance );
- PinchGestureDetector* gestureDetector = static_cast<PinchGestureDetector*>(iter->Get());
- gestureDetector->SetMinimumPinchDistance(distance);
- break;
- }
- }
-}
-
-void GestureManager::Register(const Integration::GestureRequest& request)
-{
- if (mRunning)
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "Creating %s Detector\n", GetGestureTypeString( request.type ) );
-
- switch (request.type)
- {
- case Gesture::LongPress:
- {
- GestureDetectorPtr gesture = new LongPressGestureDetector(mCoreEventInterface, mScreenSize, static_cast<const Integration::LongPressGestureRequest&>(request));
- mGestureDetectors.push_back(gesture);
- break;
- }
-
- case Gesture::Pan:
- {
- GestureDetectorPtr gesture = new PanGestureDetector(mCoreEventInterface, mScreenSize, static_cast<const Integration::PanGestureRequest&>(request), mEnvironmentOptions);
- mGestureDetectors.push_back(gesture);
- break;
- }
-
- case Gesture::Pinch:
- {
- float minPinchDistance = mMinimumDistanceDelta >= 0.0f ? mMinimumDistanceDelta : (mScreenSize.height / MINIMUM_DISTANCE_DELTA_DIVISOR);
- GestureDetectorPtr gesture = new PinchGestureDetector(mCoreEventInterface, mScreenSize, minPinchDistance);
- mGestureDetectors.push_back(gesture);
- break;
- }
-
- case Gesture::Tap:
- {
- GestureDetectorPtr gesture = new TapGestureDetector(mCoreEventInterface, mScreenSize, static_cast<const Integration::TapGestureRequest&>(request));
- mGestureDetectors.push_back(gesture);
- break;
- }
-
- default:
- DALI_ASSERT_DEBUG(false);
- break;
- }
- }
-}
-
-void GestureManager::Unregister(const Integration::GestureRequest& request)
-{
- if ( mRunning )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "Unregister: %s\n", GetGestureTypeString( request.type ) );
-
- DeleteGestureDetector( request.type );
-
- }
-}
-
-void GestureManager::Update(const Integration::GestureRequest& request)
-{
- for( GestureDetectorContainer::iterator iter = mGestureDetectors.begin(), endIter = mGestureDetectors.end(); iter < endIter; ++iter )
- {
- if ( (*iter)->GetType() == request.type )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "Update: %s\n", GetGestureTypeString( request.type ) );
- (*iter)->Update( request );
- break;
- }
- }
-}
-
-void GestureManager::DeleteGestureDetector( Gesture::Type type )
-{
- for( GestureDetectorContainer::iterator iter = mGestureDetectors.begin(), endIter = mGestureDetectors.end(); iter != endIter; ++iter )
- {
- if ( ( *iter )->GetType() == type )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "DeleteGestureDetector: %s\n", GetGestureTypeString( type ) );
- mGestureDetectors.erase( iter );
- break;
- }
- }
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_GESTURE_MANAGER_H__
-#define __DALI_INTERNAL_GESTURE_MANAGER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/integration-api/gesture-manager.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/events/gesture-detector.h>
-
-namespace Dali
-{
-
-namespace Integration
-{
-struct TouchEvent;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class CallbackManager;
-class CoreEventInterface;
-class EnvironmentOptions;
-
-/**
- * Implementation of the Integration::GestureManager.
- *
- * Contains a list of adaptor gesture detectors. It passes touch events to each required detector which
- * in turn process them to determine if their corresponding gesture has occurred.
- */
-class GestureManager : public Integration::GestureManager
-{
-public:
-
- /**
- * Constructor.
- * @param[in] coreEventInterface Used to send events to Core.
- * @param[in] screenSize The size of the screen.
- * @param[in] callbackManager used to install callbacks
- * @param[in] environmentOptions Environment Options
- */
- GestureManager(CoreEventInterface& coreEventInterface, Vector2 screenSize, CallbackManager* callbackManager, EnvironmentOptions& environmentOptions);
-
- /**
- * The destructor
- */
- virtual ~GestureManager();
-
-public:
-
- /**
- * Used by the event handler to send touch events to the Gesture Manager.
- * @param[in] event The latest touch event.
- */
- void SendEvent(const Integration::TouchEvent& event);
-
- /**
- * Used by the event handler to stop the GestureManager detection.
- */
- void Stop();
-
- /**
- * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to
- * trigger a pinch gesture
- *
- * @param[in] distance The minimum pinch distance in pixels
- */
- void SetMinimumPinchDistance(float distance);
-
-public: // GestureManager overrides
-
- /**
- * copydoc Dali::Integration::GestureManager::Register(const Integration::GestureRequest&)
- */
- virtual void Register(const Integration::GestureRequest& request);
-
- /**
- * copydoc Dali::Integration::GestureManager::Unregister(const Integration::GestureRequest&)
- */
- virtual void Unregister(const Integration::GestureRequest& request);
-
- /**
- * copydoc Dali::Integration::GestureManager::Unregister(const Integration::GestureRequest&)
- */
- virtual void Update(const Integration::GestureRequest& request);
-
-private:
-
- /**
- * Used to delete the gesture detector of the given type.
- */
- void DeleteGestureDetector( Gesture::Type type );
-
-private:
-
- typedef std::vector<GestureDetectorPtr> GestureDetectorContainer;
-
- CoreEventInterface& mCoreEventInterface;
- GestureDetectorContainer mGestureDetectors;
- Vector2 mScreenSize;
- CallbackManager* mCallbackManager;
- EnvironmentOptions& mEnvironmentOptions;
- float mMinimumDistanceDelta; ///< The minimum distance before a pinch is applicable. (-1.0f means pinch detector uses default value)
- bool mRunning; ///< States whether the GestureManager is running or not.
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_GESTURE_MANAGER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "long-press-gesture-detector.h"
-
-// EXTERNAL INCLUDES
-#include <cmath>
-
-#include <dali/public-api/events/touch-point.h>
-#include <dali/public-api/math/vector2.h>
-
-#include <dali/integration-api/events/gesture-requests.h>
-#include <dali/integration-api/events/long-press-gesture-event.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-
-#include <internal/common/system-settings.h>
-
-// INTERNAL INCLUDES
-#include <base/core-event-interface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-// TODO: Set these according to DPI
-const float MAXIMUM_MOTION_ALLOWED = 60.0f;
-// TODO: Set this time according to system setting (vconf)
-const unsigned long LONG_PRESS_TIME = 500u;
-} // unnamed namespace
-
-LongPressGestureDetector::LongPressGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::LongPressGestureRequest& request)
-: GestureDetector(screenSize, Gesture::LongPress),
- mCoreEventInterface(coreEventInterface),
- mState(Clear),
- mMinimumTouchesRequired(request.minTouches),
- mMaximumTouchesRequired(request.maxTouches),
- mTouchTime(0),
- mTimerSlot( this )
-{
- mTimer = Dali::Timer::New(GetSystemValue());
- mTimer.TickSignal().Connect( mTimerSlot, &LongPressGestureDetector::TimerCallback );
-}
-
-LongPressGestureDetector::~LongPressGestureDetector()
-{
-}
-
-void LongPressGestureDetector::SendEvent(const Integration::TouchEvent& event)
-{
- unsigned int pointCount( event.GetPointCount() );
-
- switch (mState)
- {
- // Clear: Wait till one point touches the screen before starting timer.
- case Clear:
- {
- const TouchPoint& point = event.points[0];
-
- if ( point.state == TouchPoint::Down )
- {
- mTouchPositions.clear();
- mTouchPositions[point.deviceId] = point.screen;
-
- mTouchTime = event.time;
-
- mTimer.SetInterval(GetSystemValue());
- mTimer.Start();
-
- // A long press gesture may be possible, tell Core about this and change state to Touched.
- mState = Touched;
- EmitGesture( Gesture::Possible );
- }
-
- break;
- }
-
- // Touched: Monitor movement and addition/removal of points.
- case Touched:
- {
- if (pointCount > mMaximumTouchesRequired)
- {
- // A long press did not occur, tell Core that it was cancelled and change state to Failed.
- EmitGesture( Gesture::Cancelled );
- mTouchPositions.clear();
- mTimer.Stop();
- mState = Failed;
- break;
- }
-
- bool endLoop(false);
-
- for (std::vector<TouchPoint>::const_iterator iter = event.points.begin(), endIter = event.points.end();
- iter != endIter && !endLoop; ++iter)
- {
- switch( iter->state )
- {
- // add point.
- case TouchPoint::Down:
- {
- mTouchPositions[iter->deviceId] = iter->screen;
- break;
- }
-
- // remove point.
- case TouchPoint::Up:
- case TouchPoint::Interrupted:
- {
- // System has interrupted us, long press is not possible, inform Core
- EmitGesture( Gesture::Cancelled );
- mTouchPositions.clear();
- mTimer.Stop();
- mState = ( pointCount == 1 ) ? Clear : Failed; // Change state to Clear if only one point, Failed otherwise.
- endLoop = true;
- break;
- }
-
- case TouchPoint::Motion:
- {
- const Vector2 touchPosition( mTouchPositions[iter->deviceId] - iter->screen );
- float distanceSquared = touchPosition.LengthSquared();
-
- if (distanceSquared > ( MAXIMUM_MOTION_ALLOWED * MAXIMUM_MOTION_ALLOWED ) )
- {
- // We have moved more than the allowable motion for a long press gesture. Inform Core and change state to Failed.
- EmitGesture( Gesture::Cancelled );
- mTimer.Stop();
- mState = Failed;
- endLoop = true;
- }
- break;
- }
-
- case TouchPoint::Stationary:
- case TouchPoint::Leave:
- case TouchPoint::Last:
- {
- break;
- }
- }
- }
- break;
- }
-
- // Failed/Finished: Monitor the touches, waiting for all touches to be released.
- case Failed:
- case Finished:
- {
- // eventually the final touch point will be removed, marking the end of this gesture.
- if ( pointCount == 1 )
- {
- TouchPoint::State primaryPointState = event.points[0].state;
-
- if ( (primaryPointState == TouchPoint::Up) || (primaryPointState == TouchPoint::Interrupted) )
- {
- if(mState == Finished)
- {
- // When the last touch point is lifted, we should inform the Core that the Long press has finished.
- EmitGesture(Gesture::Finished);
- }
- mTouchPositions.clear();
- mState = Clear; // Reset state to clear when last touch point is lifted.
- }
- }
- break;
- }
- }
-}
-
-void LongPressGestureDetector::Update(const Integration::GestureRequest& request)
-{
- const Integration::LongPressGestureRequest& longPress = static_cast<const Integration::LongPressGestureRequest&>(request);
-
- mMinimumTouchesRequired = longPress.minTouches;
- mMaximumTouchesRequired = longPress.maxTouches;
-}
-
-bool LongPressGestureDetector::TimerCallback()
-{
- EmitGesture(Gesture::Started);
-
- mState = Finished;
-
- // There is no touch event at this time, so ProcessEvents must be called directly
- mCoreEventInterface.ProcessCoreEvents();
-
- return false;
-}
-
-void LongPressGestureDetector::EmitGesture(Gesture::State state)
-{
- unsigned int touchPoints ( mTouchPositions.size() );
-
- // We should tell Core about the Possible and Cancelled states regardless of whether we have satisfied long press requirements.
- if ( (state == Gesture::Possible) ||
- (state == Gesture::Cancelled) ||
- (touchPoints >= mMinimumTouchesRequired) )
- {
- Integration::LongPressGestureEvent longPress( state );
- longPress.numberOfTouches = touchPoints;
-
- for (std::map<int, Vector2>::iterator iter = mTouchPositions.begin(), endIter = mTouchPositions.end();
- iter != endIter; ++iter)
- {
- longPress.point += iter->second;
- }
- longPress.point /= touchPoints;
-
- longPress.time = mTouchTime;
- if ( state != Gesture::Possible )
- {
- longPress.time += GetSystemValue();
- }
-
- mCoreEventInterface.QueueCoreEvent(longPress);
- }
-}
-
-int LongPressGestureDetector::GetSystemValue()
-{
- return GetLongPressTime( LONG_PRESS_TIME );
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__
-#define __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <map>
-#include <dali/public-api/adaptor-framework/common/timer.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/events/gesture-detector.h>
-
-namespace Dali
-{
-
-namespace Integration
-{
-struct TouchEvent;
-struct LongPressGestureRequest;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class CoreEventInterface;
-
-/**
- * When given a set of touch events, this detector attempts to determine if a long press gesture has taken place.
- * Emits a LongPressGestureEvent (state = Started) when a long press has been detected (Touch held down for more than duration).
- * Emits a further LongPressGestureEvent (state = Finished) when a long press has been completed (Touch Release).
- */
-class LongPressGestureDetector : public GestureDetector
-{
-public:
-
- /**
- * Constructor
- * @param[in] coreEventInterface Used to send events to Core.
- * @param[in] screenSize The size of the screen.
- * @param[in] request The long press gesture request.
- */
- LongPressGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::LongPressGestureRequest& request);
-
- /**
- * Virtual destructor.
- */
- virtual ~LongPressGestureDetector();
-
-public:
-
- /**
- * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
- */
- virtual void SendEvent(const Integration::TouchEvent& event);
-
- /**
- * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
- */
- virtual void Update(const Integration::GestureRequest& request);
-
-private:
-
- /**
- * Timer Callback
- * @return will return false; one-shot timer.
- */
- bool TimerCallback();
-
- /**
- * Emits the long press gesture if all conditions are applicable.
- * @param[in] state The state of this gesture event.
- */
- void EmitGesture(Gesture::State state);
-
- /**
- * Get current system setting value for tap and hold gesture
- * @return system value for tap and hold gesture [ms]
- */
- int GetSystemValue();
-
-private:
-
- /**
- * Internal state machine.
- */
- enum State
- {
- Clear, ///< No gesture detected.
- Touched, ///< User is touching the screen.
- Failed, ///< Gesture has failed.
- Finished ///< Gesture has been detected and sent.
- };
-
- CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
- State mState; ///< The current state of the detector.
-
- unsigned int mMinimumTouchesRequired; ///< The minimum touches required before emitting a long press.
- unsigned int mMaximumTouchesRequired; ///< The maximum touches allowable. Any more and a long press is not emitted.
-
- std::map<int, Vector2> mTouchPositions; ///< A map with all the touch down positions.
- unsigned long mTouchTime; ///< The time we first pressed down.
-
- Dali::Timer mTimer; ///< The timer used to determine a long press.
- SlotDelegate< LongPressGestureDetector > mTimerSlot;
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "pan-gesture-detector-base.h"
-
-// EXTERNAL INCLUDES
-#include <cmath>
-
-#include <dali/public-api/events/touch-point.h>
-
-#include <dali/integration-api/events/gesture-requests.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-
-// INTERNAL INCLUDES
-#include <base/environment-options.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-const float MINIMUM_MOTION_DISTANCE_BEFORE_PAN( 15.0f );
-const float MINIMUM_MOTION_DISTANCE_BEFORE_PAN_SQUARED( MINIMUM_MOTION_DISTANCE_BEFORE_PAN * MINIMUM_MOTION_DISTANCE_BEFORE_PAN );
-const float MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO( 2.0f / 3.0f );
-const unsigned long MAXIMUM_TIME_DIFF_ALLOWED( 500 );
-const unsigned long MINIMUM_TIME_BEFORE_THRESHOLD_ADJUSTMENTS( 100 );
-const unsigned int MINIMUM_MOTION_EVENTS_BEFORE_PAN(2);
-} // unnamed namespace
-
-PanGestureDetectorBase::PanGestureDetectorBase(Vector2 screenSize, const Integration::PanGestureRequest& request, EnvironmentOptions* environmentOptions)
-: GestureDetector( screenSize, Gesture::Pan ),
- mState( Clear ),
- mThresholdAdjustmentsRemaining( 0 ),
- mThresholdTotalAdjustments( MINIMUM_MOTION_DISTANCE_BEFORE_PAN * MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO ),
- mPrimaryTouchDownTime( 0 ),
- mMinimumTouchesRequired( request.minTouches ),
- mMaximumTouchesRequired( request.maxTouches ),
- mMinimumDistanceSquared( MINIMUM_MOTION_DISTANCE_BEFORE_PAN_SQUARED ),
- mMinimumMotionEvents( MINIMUM_MOTION_EVENTS_BEFORE_PAN ),
- mMotionEvents( 0 )
-{
- if ( environmentOptions )
- {
- int minimumDistance = environmentOptions->GetMinimumPanDistance();
- if ( minimumDistance >= 0 )
- {
- mMinimumDistanceSquared = minimumDistance * minimumDistance;
-
- // Usually, we do not want to apply the threshold straight away, but phased over the first few pans
- // Set our distance to threshold adjustments ratio here.
- mThresholdTotalAdjustments = minimumDistance * MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO;
- }
-
- int minimumEvents = environmentOptions->GetMinimumPanEvents();
- if ( minimumEvents >= 1 )
- {
- mMinimumMotionEvents = minimumEvents - 1; // Down is the first event
- }
- }
-}
-
-PanGestureDetectorBase::~PanGestureDetectorBase()
-{
-}
-
-void PanGestureDetectorBase::SendEvent(const Integration::TouchEvent& event)
-{
- TouchPoint::State primaryPointState(event.points[0].state);
-
- if (primaryPointState == TouchPoint::Interrupted)
- {
- if ( ( mState == Started ) || ( mState == Possible ) )
- {
- // If our pan had started and we are interrupted, then tell Core that pan is cancelled.
- mTouchEvents.push_back(event);
- SendPan(Gesture::Cancelled, event);
- }
- mState = Clear; // We should change our state to Clear.
- mTouchEvents.clear();
- }
- else
- {
- switch (mState)
- {
- case Clear:
- {
- if (primaryPointState == TouchPoint::Down)
- {
- mPrimaryTouchDownLocation = event.points[0].screen;
- mPrimaryTouchDownTime = event.time;
- mMotionEvents = 0;
- if (event.GetPointCount() == mMinimumTouchesRequired)
- {
- // We have satisfied the minimum touches required for a pan, tell core that a gesture may be possible and change our state accordingly.
- mState = Possible;
- SendPan(Gesture::Possible, event);
- }
-
- mTouchEvents.push_back(event);
- }
- break;
- }
-
- case Possible:
- {
- unsigned int pointCount(event.GetPointCount());
- if ( (pointCount >= mMinimumTouchesRequired)&&(pointCount <= mMaximumTouchesRequired) )
- {
- if (primaryPointState == TouchPoint::Motion)
- {
- mTouchEvents.push_back(event);
- mMotionEvents++;
-
- Vector2 delta(event.points[0].screen - mPrimaryTouchDownLocation);
-
- if ( ( mMotionEvents >= mMinimumMotionEvents ) &&
- ( delta.LengthSquared() >= mMinimumDistanceSquared ) )
- {
- // If the touch point(s) have moved enough distance to be considered a pan, then tell Core that the pan gesture has started and change our state accordingly.
- mState = Started;
- SendPan(Gesture::Started, event);
- }
- }
- else if (primaryPointState == TouchPoint::Up)
- {
- Vector2 delta(event.points[0].screen - mPrimaryTouchDownLocation);
- if(delta.LengthSquared() >= mMinimumDistanceSquared)
- {
- SendPan(Gesture::Started, event);
- mTouchEvents.push_back(event);
- SendPan(Gesture::Finished, event);
- }
- else
- {
- // If we have lifted the primary touch point then tell core the pan is cancelled and change our state to Clear.
- SendPan(Gesture::Cancelled, event);
- }
- mState = Clear;
- mTouchEvents.clear();
- }
- }
- else
- {
- // We do not satisfy pan conditions, tell Core our Gesture has been cancelled.
- SendPan(Gesture::Cancelled, event);
-
- if (pointCount == 1 && primaryPointState == TouchPoint::Up)
- {
- // If we have lifted the primary touch point, then change our state to Clear...
- mState = Clear;
- mTouchEvents.clear();
- }
- else
- {
- // ...otherwise change it to Failed.
- mState = Failed;
- }
- }
- break;
- }
-
- case Started:
- {
- mTouchEvents.push_back(event);
-
- unsigned int pointCount(event.GetPointCount());
- if ( (pointCount >= mMinimumTouchesRequired)&&(pointCount <= mMaximumTouchesRequired) )
- {
- switch (primaryPointState)
- {
- case TouchPoint::Motion:
- // Pan is continuing, tell Core.
- SendPan(Gesture::Continuing, event);
- break;
-
- case TouchPoint::Up:
- // Pan is finally finished when our primary point is lifted, tell Core and change our state to Clear.
- SendPan(Gesture::Finished, event);
- mState = Clear;
- mTouchEvents.clear();
- break;
-
- case TouchPoint::Stationary:
- if (pointCount == mMinimumTouchesRequired)
- {
- std::vector<TouchPoint>::const_iterator iter = event.points.begin() + 1; // We already know the state of the first point
- for(; iter != event.points.end(); ++iter)
- {
- if(iter->state == TouchPoint::Up)
- {
- // The number of touch points will be less than the minimum required. Inform core and change our state to Finished.
- SendPan(Gesture::Finished, event);
- mState = Finished;
- break;
- }
- }
- }
- break;
-
- default:
- break;
- }
- }
- else
- {
- // We have gone outside of the pan requirements, inform Core that the gesture is finished.
- SendPan(Gesture::Finished, event);
-
- if (pointCount == 1 && primaryPointState == TouchPoint::Up)
- {
- // If this was the primary point being released, then we change our state back to Clear...
- mState = Clear;
- mTouchEvents.clear();
- }
- else
- {
- // ...otherwise we change it to Finished.
- mState = Finished;
- }
- }
- break;
- }
-
- case Finished:
- case Failed:
- {
- if (primaryPointState == TouchPoint::Up)
- {
- // Change our state back to clear when the primary touch point is released.
- mState = Clear;
- mTouchEvents.clear();
- }
- break;
- }
- }
- }
-}
-
-void PanGestureDetectorBase::Update(const Integration::GestureRequest& request)
-{
- const Integration::PanGestureRequest& pan = static_cast<const Integration::PanGestureRequest&>(request);
-
- mMinimumTouchesRequired = pan.minTouches;
- mMaximumTouchesRequired = pan.maxTouches;
-}
-
-void PanGestureDetectorBase::SendPan(Gesture::State state, const Integration::TouchEvent& currentEvent)
-{
- Integration::PanGestureEvent gesture(state);
- gesture.currentPosition = currentEvent.points[0].screen;
- gesture.numberOfTouches = currentEvent.GetPointCount();
-
- if ( mTouchEvents.size() > 1 )
- {
- // Get the second last event in the queue, the last one is the current event
- const Integration::TouchEvent& previousEvent( *( mTouchEvents.rbegin() + 1 ) );
-
- Vector2 previousPosition( mPreviousPosition );
- unsigned long previousTime( previousEvent.time );
-
- // If we've just started then we want to remove the threshold from Core calculations.
- if ( state == Gesture::Started )
- {
- previousPosition = mPrimaryTouchDownLocation;
- previousTime = mPrimaryTouchDownTime;
-
- // If it's a slow pan, we do not want to phase in the threshold over the first few pan-events
- // A slow pan is defined as one that starts the specified number of milliseconds after the down-event
- if ( ( currentEvent.time - previousTime ) > MINIMUM_TIME_BEFORE_THRESHOLD_ADJUSTMENTS )
- {
- mThresholdAdjustmentsRemaining = mThresholdTotalAdjustments;
- mThresholdAdjustmentPerFrame = ( gesture.currentPosition - previousPosition ) / mThresholdTotalAdjustments;
- }
- else
- {
- mThresholdAdjustmentsRemaining = 0;
- mThresholdAdjustmentPerFrame = Vector2::ZERO;
- }
- }
-
- gesture.previousPosition = previousPosition;
- gesture.timeDelta = currentEvent.time - previousTime;
-
- // Apply the threshold with a phased approach
- if ( mThresholdAdjustmentsRemaining > 0 )
- {
- --mThresholdAdjustmentsRemaining;
- gesture.currentPosition -= mThresholdAdjustmentPerFrame * mThresholdAdjustmentsRemaining;
- }
-
- mPreviousPosition = gesture.currentPosition;
- }
- else
- {
- gesture.previousPosition = gesture.currentPosition;
- gesture.timeDelta = 0;
- }
-
- gesture.time = currentEvent.time;
-
- EmitPan(gesture);
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_PAN_GESTURE_DETECTOR_BASE_H__
-#define __DALI_INTERNAL_PAN_GESTURE_DETECTOR_BASE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/events/gesture-detector.h>
-
-namespace Dali
-{
-
-namespace Integration
-{
-class Core;
-struct TouchEvent;
-struct PanGestureRequest;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class EnvironmentOptions;
-
-/**
- * When given a set of touch events, this detector attempts to determine if a pan gesture has taken place.
- */
-class PanGestureDetectorBase : public GestureDetector
-{
-public:
-
- /**
- * Virtual destructor.
- */
- virtual ~PanGestureDetectorBase();
-
-public:
-
- /**
- * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
- */
- virtual void SendEvent(const Integration::TouchEvent& event);
-
- /**
- * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
- */
- virtual void Update(const Integration::GestureRequest& request);
-
-protected:
-
- /**
- * Constructor
- * @param[in] screenSize The size of the screen.
- * @param[in] request The details of the request.
- */
- PanGestureDetectorBase(Vector2 screenSize, const Integration::PanGestureRequest& request, EnvironmentOptions* environmentOptions);
-
-private:
-
- /**
- * Emits the pan gesture event (performs some smoothing operation).
- * @param[in] state The state of the pan.
- * @param[in] currentEvent The latest touch event.
- */
- void SendPan(Gesture::State state, const Integration::TouchEvent& currentEvent);
-
- /**
- * Emits the pan gesture event to the core.
- * @param[in] gesture The pan gesture event.
- */
- virtual void EmitPan(const Integration::PanGestureEvent gesture) = 0;
-
-private:
-
- /**
- * Internal state machine.
- */
- enum State
- {
- Clear, ///< No gesture detected.
- Possible, ///< The current touch event data suggests that a gesture is possible.
- Started, ///< A gesture has been detected.
- Finished, ///< A previously started pan gesture has finished.
- Failed, ///< Current touch event data suggests a pan gesture is not possible.
- };
-
- State mState; ///< The current state of the detector.
- std::vector<Integration::TouchEvent> mTouchEvents; ///< A container of all touch events after an initial down event.
-
- Vector2 mPrimaryTouchDownLocation; ///< The initial touch down point.
- Vector2 mThresholdAdjustmentPerFrame; ///< The adjustment per frame at the start of a slow pan.
- Vector2 mPreviousPosition; ///< The previous position.
-
- unsigned int mThresholdAdjustmentsRemaining; ///< No. of threshold adjustments still to apply (for a slow-pan).
- unsigned int mThresholdTotalAdjustments; ///< The total number of adjustments required.
-
- unsigned long mPrimaryTouchDownTime; ///< The initial touch down time.
- unsigned int mMinimumTouchesRequired; ///< The minimum touches required before a pan should be emitted.
- unsigned int mMaximumTouchesRequired; ///< The maximum touches after which a pan should not be emitted.
-
- unsigned int mMinimumDistanceSquared; ///< The minimum distance squared before pan should start.
- unsigned int mMinimumMotionEvents; ///< The minimum motion events before pan should start.
- unsigned int mMotionEvents; ///< The motion events received so far (before pan is emitted).
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_PAN_GESTURE_DETECTOR_BASE_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "pan-gesture-detector.h"
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/events/gesture-requests.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-
-// INTERNAL INCLUDES
-#include <base/core-event-interface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-PanGestureDetector::PanGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::PanGestureRequest& request, EnvironmentOptions& environmentOptions)
-: PanGestureDetectorBase(screenSize, request, &environmentOptions),
- mCoreEventInterface(coreEventInterface)
-{
-}
-
-PanGestureDetector::~PanGestureDetector()
-{
-}
-
-void PanGestureDetector::EmitPan(const Integration::PanGestureEvent event)
-{
- mCoreEventInterface.QueueCoreEvent(event);
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_PAN_GESTURE_DETECTOR_H__
-#define __DALI_INTERNAL_PAN_GESTURE_DETECTOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/math/vector2.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/events/pan-gesture-detector-base.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
-
-namespace Dali
-{
-
-namespace Integration
-{
-struct TouchEvent;
-struct PanGestureRequest;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class CoreEventInterface;
-
-/**
- * Detects a pan gesture and sends it to core.
- */
-class PanGestureDetector : public PanGestureDetectorBase
-{
-public:
-
- /**
- * Constructor
- * @param[in] coreEventInterface Used to send events to Core.
- * @param[in] screenSize The size of the screen.
- * @param[in] request The details of the request.
- * @param[in] environmentOptions The environmentOptions.
- */
- PanGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::PanGestureRequest& request, EnvironmentOptions& environmentOptions);
-
- /**
- * Virtual destructor.
- */
- virtual ~PanGestureDetector();
-
-private:
-
- /**
- * Emits the pan gesture event to the core.
- * @param[in] gesture The pan gesture event.
- */
- virtual void EmitPan(const Integration::PanGestureEvent gesture);
-
-private:
-
- CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_PAN_GESTURE_DETECTOR_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "pinch-gesture-detector.h"
-
-// EXTERNAL INCLUDES
-#include <cmath>
-
-#include <dali/public-api/events/touch-point.h>
-#include <dali/public-api/math/vector2.h>
-
-#include <dali/integration-api/events/pinch-gesture-event.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-
-// INTERNAL INCLUDES
-#include <base/core-event-interface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED = 4;
-const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START = 4;
-
-inline float GetDistance(const TouchPoint& point1, const TouchPoint& point2)
-{
- Vector2 vector(point1.screen - point2.screen);
- return vector.Length();
-}
-
-inline float GetGradient(const TouchPoint& point1, const TouchPoint& point2)
-{
- return (point2.screen.y - point1.screen.y)
- /
- (point2.screen.x - point1.screen.x);
-}
-
-inline Vector2 GetCenterPoint(const TouchPoint& point1, const TouchPoint& point2)
-{
- return Vector2(point1.screen + point2.screen) * 0.5f;
-}
-
-} // unnamed namespace
-
-PinchGestureDetector::PinchGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, float minimumPinchDistance)
-: GestureDetector(screenSize, Gesture::Pinch),
- mCoreEventInterface(coreEventInterface),
- mState(Clear),
- mTouchEvents(),
- mMinimumDistanceDelta(minimumPinchDistance),
- mStartingDistance(0.0f)
-{
-}
-
-PinchGestureDetector::~PinchGestureDetector()
-{
-}
-
-void PinchGestureDetector::SetMinimumPinchDistance(float distance)
-{
- mMinimumDistanceDelta = distance;
-}
-
-void PinchGestureDetector::SendEvent(const Integration::TouchEvent& event)
-{
- int pointCount = event.GetPointCount();
-
- switch (mState)
- {
- case Clear:
- {
- if (pointCount == 2)
- {
- // Change state to possible as we have two touch points.
- mState = Possible;
- mTouchEvents.push_back(event);
- }
- break;
- }
-
- case Possible:
- {
- if (pointCount != 2)
- {
- // We no longer have two touch points so change state back to Clear.
- mState = Clear;
- mTouchEvents.clear();
- }
- else
- {
- const TouchPoint& currentPoint1 = event.points[0];
- const TouchPoint& currentPoint2 = event.points[1];
-
- if (currentPoint1.state == TouchPoint::Up || currentPoint2.state == TouchPoint::Up)
- {
- // One of our touch points has an Up event so change our state back to Clear.
- mState = Clear;
- mTouchEvents.clear();
- }
- else
- {
- mTouchEvents.push_back(event);
-
- // We can only determine a pinch after a certain number of touch points have been collected.
- if (mTouchEvents.size() >= MINIMUM_TOUCH_EVENTS_REQUIRED)
- {
- const TouchPoint& firstPoint1 = mTouchEvents[0].points[0];
- const TouchPoint& firstPoint2 = mTouchEvents[0].points[1];
-
- float firstDistance = GetDistance(firstPoint1, firstPoint2);
- float currentDistance = GetDistance(currentPoint1, currentPoint2);
- float distanceChanged = firstDistance - currentDistance;
-
- // Check if distance has changed enough
- if (fabsf(distanceChanged) > mMinimumDistanceDelta)
- {
- // Remove the first few events from the vector otherwise values are exaggerated
- mTouchEvents.erase(mTouchEvents.begin(), mTouchEvents.end() - MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START);
-
- if ( !mTouchEvents.empty() )
- {
- mStartingDistance = GetDistance(mTouchEvents.begin()->points[0], mTouchEvents.begin()->points[1]);
-
- // Send pinch started
- SendPinch(Gesture::Started, event);
-
- mState = Started;
- }
-
- mTouchEvents.clear();
- }
-
- if (mState == Possible)
- {
- // No pinch, so restart detection
- mState = Clear;
- mTouchEvents.clear();
- }
- }
- }
- }
- break;
- }
-
- case Started:
- {
- if (pointCount != 2)
- {
- // Send pinch finished event
- SendPinch(Gesture::Finished, event);
-
- mState = Clear;
- mTouchEvents.clear();
- }
- else
- {
- const TouchPoint& currentPoint1 = event.points[0];
- const TouchPoint& currentPoint2 = event.points[1];
-
- if (currentPoint1.state == TouchPoint::Up || currentPoint2.state == TouchPoint::Up)
- {
- mTouchEvents.push_back(event);
- // Send pinch finished event
- SendPinch(Gesture::Finished, event);
-
- mState = Clear;
- mTouchEvents.clear();
- }
- else
- {
- mTouchEvents.push_back(event);
-
- if (mTouchEvents.size() >= MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START)
- {
- // Send pinch continuing
- SendPinch(Gesture::Continuing, event);
-
- mTouchEvents.clear();
- }
- }
- }
- break;
- }
- }
-}
-
-void PinchGestureDetector::Update(const Integration::GestureRequest& request)
-{
- // Nothing to do.
-}
-
-void PinchGestureDetector::SendPinch(Gesture::State state, const Integration::TouchEvent& currentEvent)
-{
- Integration::PinchGestureEvent gesture(state);
-
- if ( !mTouchEvents.empty() )
- {
- const Integration::TouchEvent& firstEvent = mTouchEvents[0];
-
- // Assert if we have been holding TouchEvents that do not have 2 points
- DALI_ASSERT_DEBUG( firstEvent.GetPointCount() == 2 );
-
- // We should use the current event in our calculations unless it does not have two points.
- // If it does not have two points, then we should use the last point in mTouchEvents.
- Integration::TouchEvent event( currentEvent );
- if ( event.GetPointCount() != 2 )
- {
- event = *mTouchEvents.rbegin();
- }
-
- const TouchPoint& firstPoint1( firstEvent.points[0] );
- const TouchPoint& firstPoint2( firstEvent.points[1] );
- const TouchPoint& currentPoint1( event.points[0] );
- const TouchPoint& currentPoint2( event.points[1] );
-
- float firstDistance = GetDistance(firstPoint1, firstPoint2);
- float currentDistance = GetDistance(currentPoint1, currentPoint2);
- gesture.scale = currentDistance / mStartingDistance;
-
- float distanceDelta = fabsf(firstDistance - currentDistance);
- unsigned long timeDelta = currentEvent.time - firstEvent.time;
- gesture.speed = (distanceDelta / timeDelta) * 1000.0f;
-
- gesture.centerPoint = GetCenterPoint(currentPoint1, currentPoint2);
- }
- else
- {
- // Something has gone wrong, just cancel the gesture.
- gesture.state = Gesture::Cancelled;
- }
-
- gesture.time = currentEvent.time;
-
- mCoreEventInterface.QueueCoreEvent(gesture);
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H__
-#define __DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/events/gesture-detector.h>
-
-namespace Dali
-{
-
-namespace Integration
-{
-struct TouchEvent;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class CoreEventInterface;
-
-/**
- * When given a set of touch events, this detector attempts to determine if a pinch gesture has taken place.
- */
-class PinchGestureDetector : public GestureDetector
-{
-public:
-
- /**
- * Constructor
- * @param[in] coreEventInterface Used to send events to Core.
- * @param[in] screenSize The size of the screen.
- */
- PinchGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, float minimumPinchDistance);
-
- /**
- * Virtual destructor.
- */
- virtual ~PinchGestureDetector();
-
- /**
- * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to
- * trigger a pinch gesture
- *
- * @param[in] distance The minimum pinch distance in pixels
- */
- void SetMinimumPinchDistance(float distance);
-
-public:
-
- /**
- * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
- */
- virtual void SendEvent(const Integration::TouchEvent& event);
-
- /**
- * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
- */
- virtual void Update(const Integration::GestureRequest& request);
-
-private:
-
- /**
- * Emits the pinch gesture event to the core.
- * @param[in] state The state of the pinch (whether it's starting, continuing or finished).
- * @param[in] currentEvent The latest touch event.
- */
- void SendPinch(Gesture::State state, const Integration::TouchEvent& currentEvent);
-
-private:
-
- /**
- * Internal state machine.
- */
- enum State
- {
- Clear, ///< No gesture detected.
- Possible, ///< The current touch event data suggests that a gesture is possible.
- Started, ///< A gesture has been detected.
- };
-
- CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
- State mState; ///< The current state of the detector.
- std::vector<Integration::TouchEvent> mTouchEvents; ///< The touch events since initial touch down.
-
- float mMinimumDistanceDelta; ///< The minimum distance before a pinch is applicable.
-
- float mStartingDistance; ///< The distance between the two touch points when the pinch is first detected.
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "tap-gesture-detector.h"
-
-// EXTERNAL INCLUDES
-#include <cmath>
-
-#include <dali/public-api/events/touch-point.h>
-#include <dali/public-api/math/vector2.h>
-
-#include <dali/integration-api/events/gesture-requests.h>
-#include <dali/integration-api/events/tap-gesture-event.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-#include <base/core-event-interface.h>
-
-// INTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-// TODO: Set these according to DPI
-const float MAXIMUM_MOTION_ALLOWED = 20.0f;
-const unsigned long MAXIMUM_TIME_ALLOWED = 300u;
-} // unnamed namespace
-
-TapGestureDetector::TapGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::TapGestureRequest& request)
-: GestureDetector(screenSize, Gesture::Tap),
- mCoreEventInterface(coreEventInterface),
- mState(Clear),
- mMinimumTapsRequired(request.minTaps),
- mMaximumTapsRequired(request.maxTaps),
- mTapsRegistered(0),
- mTimerSlot( this )
-{
- mTimer = Dali::Timer::New(MAXIMUM_TIME_ALLOWED);
- mTimer.TickSignal().Connect( mTimerSlot, &TapGestureDetector::TimerCallback );
-}
-
-TapGestureDetector::~TapGestureDetector()
-{
-}
-
-void TapGestureDetector::SendEvent(const Integration::TouchEvent& event)
-{
- if (event.GetPointCount() == 1)
- {
- const TouchPoint& point = event.points[0];
- TouchPoint::State pointState = point.state;
-
- switch (mState)
- {
- case Clear:
- {
- if (pointState == TouchPoint::Down)
- {
- mTouchPosition.x = point.screen.x;
- mTouchPosition.y = point.screen.y;
- mTouchTime = event.time;
- mTapsRegistered = 0;
- mState = Touched;
- EmitGesture( Gesture::Possible, mTouchTime );
- }
- break;
- }
-
- case Touched:
- {
- Vector2 distanceDelta(abs(mTouchPosition.x - point.screen.x),
- abs(mTouchPosition.y - point.screen.y));
-
- unsigned long timeDelta = abs(event.time - mTouchTime);
-
- if (distanceDelta.x > MAXIMUM_MOTION_ALLOWED ||
- distanceDelta.y > MAXIMUM_MOTION_ALLOWED ||
- timeDelta > MAXIMUM_TIME_ALLOWED)
- {
- // We may have already registered some taps so try emitting the gesture
- EmitGesture( mTapsRegistered ? Gesture::Started : Gesture::Cancelled, event.time );
- mState = (pointState == TouchPoint::Motion) ? Failed : Clear;
- mTimer.Stop();
- }
-
- if (mState == Touched && pointState == TouchPoint::Up)
- {
- ++mTapsRegistered;
-
- if (mTapsRegistered < mMaximumTapsRequired)
- {
- // Only emit gesture after timer expires if asked for multiple taps.
- mState = Registered;
- mTimer.Start();
- }
- else
- {
- EmitGesture(Gesture::Started, event.time);
- mState = Clear;
- mTimer.Stop();
- }
- }
- break;
- }
-
- case Registered:
- {
- if (pointState == TouchPoint::Down)
- {
- mTimer.Stop();
-
- Vector2 distanceDelta(abs(mTouchPosition.x - point.screen.x),
- abs(mTouchPosition.y - point.screen.y));
-
- // Check if subsequent tap is in a different position, if not then emit the previous tap
- // count gesture (if required),
- if (distanceDelta.x > MAXIMUM_MOTION_ALLOWED ||
- distanceDelta.y > MAXIMUM_MOTION_ALLOWED)
- {
- EmitGesture(Gesture::Started, event.time);
- mTouchPosition.x = point.screen.x;
- mTouchPosition.y = point.screen.y;
- }
-
- mTouchTime = event.time;
- mState = Touched;
- mTimer.Start();
- }
- break;
- }
-
- case Failed:
- {
- if (pointState == TouchPoint::Up)
- {
- mState = Clear;
- }
- break;
- }
-
- default:
- mState = Clear;
- break;
- }
- }
- else
- {
- mState = Failed;
-
- // We have entered a multi-touch event so emit registered gestures if required.
- EmitGesture(Gesture::Started, event.time);
- }
-}
-
-void TapGestureDetector::Update(const Integration::GestureRequest& request)
-{
- const Integration::TapGestureRequest& tap = static_cast<const Integration::TapGestureRequest&>(request);
-
- mMinimumTapsRequired = tap.minTaps;
- mMaximumTapsRequired = tap.maxTaps;
-}
-
-bool TapGestureDetector::TimerCallback()
-{
- EmitGesture( ( mTapsRegistered >= mMinimumTapsRequired ? Gesture::Started : Gesture::Cancelled ), mTouchTime + MAXIMUM_TIME_ALLOWED);
- mState = Clear;
- return false;
-}
-
-void TapGestureDetector::EmitGesture( Gesture::State state, unsigned int time )
-{
- if ( (state == Gesture::Possible) ||
- (state == Gesture::Cancelled) ||
- (mTapsRegistered >= mMinimumTapsRequired && mTapsRegistered <= mMaximumTapsRequired) )
- {
- Integration::TapGestureEvent event( state );
- event.numberOfTaps = mTapsRegistered;
- event.point = mTouchPosition;
- event.time = time;
-
- mCoreEventInterface.QueueCoreEvent(event);
- }
- mTapsRegistered = 0;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__
-#define __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/adaptor-framework/common/timer.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/events/gesture-detector.h>
-
-namespace Dali
-{
-
-namespace Integration
-{
-struct TouchEvent;
-struct TapGestureRequest;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class CoreEventInterface;
-
-/**
- * When given a set of touch events, this detector attempts to determine if a tap gesture has taken place.
- */
-class TapGestureDetector : public GestureDetector
-{
-public:
-
- /**
- * Constructor
- * @param[in] coreEventInterface Used to send events to Core.
- * @param[in] screenSize The size of the screen.
- * @param[in] request The tap gesture request.
- */
- TapGestureDetector(CoreEventInterface& coreEventInterface, Vector2 screenSize, const Integration::TapGestureRequest& request);
-
- /**
- * Virtual destructor.
- */
- virtual ~TapGestureDetector();
-
-public:
-
- /**
- * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
- */
- virtual void SendEvent(const Integration::TouchEvent& event);
-
- /**
- * @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
- */
- virtual void Update(const Integration::GestureRequest& request);
-
-private:
-
- /**
- * Timer Callback
- * @return will return false; one-shot timer.
- */
- bool TimerCallback();
-
- /**
- * Checks if registered taps are within required bounds and emits tap gesture if they are.
- */
- void EmitGesture( Gesture::State state, unsigned int time );
-
-private:
-
- /**
- * Internal state machine.
- */
- enum State
- {
- Clear, ///< No gesture detected.
- Touched, ///< User is touching the screen.
- Registered, ///< At least one tap has been registered.
- Failed, ///< Gesture has failed.
- };
-
- CoreEventInterface& mCoreEventInterface; ///< Used to send events to Core.
- State mState; ///< Current state of the detector.
-
- int mMinimumTapsRequired; ///< Minimum number of taps required.
- int mMaximumTapsRequired; ///< Maximum number of taps required.
- int mTapsRegistered; ///< In current detection, the number of taps registered.
-
- Vector2 mTouchPosition; ///< The initial touch down position.
- unsigned long mTouchTime; ///< The initial touch down time.
-
- Dali::Timer mTimer; ///< The timer to start when we have registered the tap. We have to register all taps within a certain time frame.
- SlotDelegate< TapGestureDetector > mTimerSlot;
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__
+++ /dev/null
-//******************************************************************************
-//
-// Default feedback theme for dali-toolkit
-//
-//******************************************************************************
-{
- "style":
- {
- "PushButton":
- {
- "signals":
- [
- {
- "type": "clicked",
- "sound-feedback-pattern": "FEEDBACK_PATTERN_TAP"
- }
- ]
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <internal/common/feedback/feedback-controller.h>
-
-// EXTERNAL INCLUDES
-#include <sstream>
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/json_parser.hpp>
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/common/stage.h>
-#include <dali/public-api/object/object-registry.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/feedback/feedback-ids.h>
-#include <internal/common/feedback/feedback-plugin-proxy.h>
-
-using std::string;
-using boost::property_tree::ptree;
-
-namespace // unnamed namespace
-{
-
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::General, false, "LOG_FEEDBACK_CONTROLLER");
-#endif
-
-const char* DEFAULT_FEEDBACK_THEME_PATH = DALI_FEEDBACK_THEME_DIR"default-feedback-theme.json";
-
-string LoadFile(const string& filename)
-{
- DALI_ASSERT_DEBUG( 0 != filename.length());
-
- string contents;
-
- std::filebuf buf;
- buf.open(filename.c_str(), std::ios::in);
- if( buf.is_open() )
- {
- std::istream stream(&buf);
-
- // determine data length
- stream.seekg(0, std::ios_base::end);
- unsigned int length = static_cast<unsigned int>( stream.tellg() );
- stream.seekg(0, std::ios_base::beg);
-
- // allocate a buffer
- contents.resize(length);
- // read data into buffer
- stream.read(&contents[0], length);
-
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceLoader::LoadFile(%s) - loaded %d bytes\n", filename.c_str(), length );
- }
- else
- {
- DALI_LOG_ERROR("ResourceLoader::LoadFile(%s) - failed to load\n", filename.c_str());
- }
-
- return contents;
-}
-
-static string FindFilename( const ptree& child )
-{
- boost::optional<string> filename = child.get_optional<string>( "filename" );
- DALI_ASSERT_ALWAYS( filename && "Filename definiton must have 'filename'" );
-
- struct stat buf;
-
- if( 0 == stat( (*filename).c_str(), &buf) )
- {
- return *filename;
- }
-
- // else not found
- return "";
-}
-
-} // unnamed namespace
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-struct SignalFeedbackInfo
-{
- /**
- * Default constructor.
- * @deprecated - moved into dali-adaptor FeedbackController.
- */
- SignalFeedbackInfo()
- :mHasHapticFeedbackInfo(false),
- mHasSoundFeedbackInfo(false)
- {
- }
-
- string mSignalName;
- bool mHasHapticFeedbackInfo;
- bool mHasSoundFeedbackInfo;
- string mHapticFeedbackPattern;
- string mSoundFeedbackPattern;
- string mHapticFeedbackFile;
- string mSoundFeedbackFile;
-};
-
-typedef std::vector<SignalFeedbackInfo> SignalFeedbackInfoContainer;
-typedef SignalFeedbackInfoContainer::const_iterator SignalFeedbackInfoConstIter;
-
-struct FeedbackStyleInfo
-{
- /**
- * Default constructor.
- * @deprecated - moved into dali-adaptor FeedbackController.
- */
- FeedbackStyleInfo()
- {
- }
-
- string mTypeName;
- std::vector<SignalFeedbackInfo> mSignalFeedbackInfoList;
-};
-
-static const FeedbackStyleInfo DEFAULT_FEEDBACK_STYLE_INFO;
-
-FeedbackController::FeedbackController( FeedbackPluginProxy& plugin )
-: mPlugin( plugin ),
- mConnections( this )
-{
- string defaultTheme = LoadFile( DEFAULT_FEEDBACK_THEME_PATH );
- LoadTheme( defaultTheme );
-
- Dali::ObjectRegistry registry = Dali::Stage::GetCurrent().GetObjectRegistry();
-
- registry.ObjectCreatedSignal().Connect( mConnections, &FeedbackController::ObjectCreatedCallback );
-
- Dali::StyleMonitor styleMonitor( Dali::StyleMonitor::Get() );
- DALI_ASSERT_DEBUG( styleMonitor && "StyleMonitor not available" );
- styleMonitor.StyleChangeSignal().Connect( mConnections, &FeedbackController::StyleChangedCallback );
-}
-
-FeedbackController::~FeedbackController()
-{
-}
-
-struct PlayFeedbackFromSignal
-{
- PlayFeedbackFromSignal( FeedbackController& controller, const string& typeName, const string& signalName )
- : mController( controller ),
- mTypeName( typeName ),
- mSignalName( signalName )
- {
- }
-
- void operator()()
- {
- mController.PlayFeedback( mTypeName, mSignalName );
- }
-
- FeedbackController& mController;
- string mTypeName;
- string mSignalName;
-};
-
-void FeedbackController::ObjectCreatedCallback( BaseHandle handle )
-{
- if( handle )
- {
- string type = handle.GetTypeName();
-
- const FeedbackStyleInfo styleInfo = GetStyleInfo( type );
-
- for( SignalFeedbackInfoConstIter iter = styleInfo.mSignalFeedbackInfoList.begin(); iter != styleInfo.mSignalFeedbackInfoList.end(); ++iter )
- {
- const SignalFeedbackInfo& info = *iter;
-
- if( info.mHasHapticFeedbackInfo || info.mHasSoundFeedbackInfo )
- {
- if( !info.mHapticFeedbackPattern.empty() || !info.mHapticFeedbackFile.empty() ||
- !info.mSoundFeedbackPattern.empty() || !info.mSoundFeedbackFile.empty() )
- {
- handle.ConnectSignal( this,
- info.mSignalName,
- PlayFeedbackFromSignal( *this, type, info.mSignalName ) );
-
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FeedbackController::ObjectCreatedCallback found Haptic pattern %s for Object type: %s, Signal Type: %s\n",
- info.mHapticFeedbackPattern.c_str(), type.c_str(), info.mSignalName.c_str() );
- }
- else
- {
- DALI_LOG_ERROR("FeedbackController::ObjectCreatedCallback() Warning Inconsistent data in theme file!\n");
- }
- }
- }
- }
-}
-
-const FeedbackStyleInfo& FeedbackController::GetStyleInfo( const string& type ) const
-{
- std::map<const string, FeedbackStyleInfo>::const_iterator iter( mStyleInfoLut.find( type ) );
- if( iter != mStyleInfoLut.end() )
- {
- return iter->second;
- }
- else
- {
- return DEFAULT_FEEDBACK_STYLE_INFO;
- }
-}
-
-void FeedbackController::StyleChangedCallback( Dali::StyleMonitor styleMonitor, Dali::StyleChange styleChange )
-{
- if( styleChange.themeChange )
- {
- const string& userDefinedThemePath = styleChange.themeFilePath;
- const string& userDefinedTheme = LoadFile( userDefinedThemePath );
-
- if( !LoadTheme( userDefinedTheme ) )
- {
- DALI_LOG_ERROR("FeedbackController::StyleChangedCallback() User defined theme failed to load! \n");
-
- //If there is any problem is using the user defined theme, then fall back to default theme
- if( !LoadTheme( DEFAULT_FEEDBACK_THEME_PATH ) )
- {
- //If the default theme fails, Then No luck!
- DALI_LOG_ERROR("FeedbackController::StyleChangedCallback() Default theme failed to load! \n");
- }
- }
- }
-}
-
-bool FeedbackController::LoadTheme( const string& data )
-{
- bool result = false;
-
- try
- {
- LoadFromString( data );
-
- result = true;
- }
- catch(...)
- {
- //Problem in user set theme, So fallback to use default theme.
- DALI_LOG_ERROR( "FeedbackController::LoadTheme() Failed to load theme\n" );
- }
-
- return result;
-}
-
-void FeedbackController::LoadFromString( const string& data )
-{
- std::stringstream jsonData( data );
-
- ptree node;
-
- try
- {
- // tree root is cleared each read_json
- boost::property_tree::json_parser::read_json( jsonData, node );
- }
- catch( boost::property_tree::json_parser::json_parser_error& error )
- {
- DALI_LOG_WARNING( "JSON Parse Error:'%s'\n", error.message().c_str() );
- DALI_LOG_WARNING( "JSON Parse File :'%s'\n", error.filename().c_str() );
- DALI_LOG_WARNING( "JSON Parse Line :'%d'\n", error.line() );
- throw;
- }
- catch(...)
- {
- throw;
- }
-
- // Clear previously loaded style
-
- mSoundFilesLut.clear();
- mHapticFilesLut.clear();
- mStyleInfoLut.clear();
-
- // Parse filenames
-
- if ( node.get_child_optional("sounds") )
- {
- const ptree& soundsNode = node.get_child( "sounds" );
- const ptree::const_iterator endSoundsIter = soundsNode.end();
- for( ptree::const_iterator iter = soundsNode.begin(); endSoundsIter != iter; ++iter )
- {
- const ptree::value_type& keyChild = *iter;
-
- string key( keyChild.first );
-
- boost::optional<string> name( keyChild.second.get_optional<string>("filename") );
- if( name )
- {
- string fileName( FindFilename( keyChild.second ) );
-
- mSoundFilesLut.insert( std::pair<const string, const string>(key, fileName) );
- }
- else
- {
- DALI_LOG_WARNING("Invalid sound file\n");
- }
- }
- }
-
- if ( node.get_child_optional("haptic") )
- {
- const ptree& hapticNode = node.get_child( "haptic" );
- const ptree::const_iterator endHapticIter = hapticNode.end();
- for( ptree::const_iterator iter = hapticNode.begin(); endHapticIter != iter; ++iter )
- {
- const ptree::value_type& keyChild = *iter;
-
- string key( keyChild.first );
-
- boost::optional<string> name( keyChild.second.get_optional<string>("filename") );
- if( name )
- {
- string fileName( FindFilename( keyChild.second ) );
-
- mHapticFilesLut.insert( std::pair<const string, const string>(key, fileName) );
- }
- else
- {
- DALI_LOG_WARNING("Invalid haptic file\n");
- }
- }
- }
-
- // Parse style
-
- const ptree& styleNode = node.get_child( "style" );
- const ptree::const_iterator endIter = styleNode.end();
- for( ptree::const_iterator iter = styleNode.begin(); endIter != iter; ++iter )
- {
- const ptree::value_type& keyChild = *iter;
-
- string key( keyChild.first );
- FeedbackStyleInfo themeInfo;
- themeInfo.mTypeName = key;
-
- const ptree& signalsNode = keyChild.second.get_child( "signals" );
- const ptree::const_iterator endIter = signalsNode.end();
- for( ptree::const_iterator iter = signalsNode.begin(); endIter != iter; ++iter )
- {
- const ptree::value_type& signal_child = *iter;
-
- SignalFeedbackInfo signalFeedbackInfo;
-
- boost::optional<string> type( signal_child.second.get_optional<string>( "type" ) );
- DALI_ASSERT_ALWAYS( type && "Signal must have a type" );
-
- signalFeedbackInfo.mSignalName = *type;
-
- boost::optional<string> hapticFeedbackPattern( signal_child.second.get_optional<string>( "haptic-feedback-pattern" ) );
- if( hapticFeedbackPattern )
- {
- signalFeedbackInfo.mHasHapticFeedbackInfo = true;
- signalFeedbackInfo.mHapticFeedbackPattern = *hapticFeedbackPattern;
- }
-
- boost::optional<string> hapticFeedbackFile( signal_child.second.get_optional<string>( "haptic-feedback-file" ) );
- if( hapticFeedbackFile )
- {
- signalFeedbackInfo.mHasHapticFeedbackInfo = true;
- signalFeedbackInfo.mHapticFeedbackFile = GetHapticPath( *hapticFeedbackFile );
- }
-
- boost::optional<string> soundFeedbackPattern( signal_child.second.get_optional<string>( "sound-feedback-pattern" ) );
- if( soundFeedbackPattern )
- {
- signalFeedbackInfo.mHasSoundFeedbackInfo = true;
- signalFeedbackInfo.mSoundFeedbackPattern = *soundFeedbackPattern;
- }
-
- boost::optional<string> soundFeedbackFile( signal_child.second.get_optional<string>( "sound-feedback-file" ) );
- if( soundFeedbackFile )
- {
- signalFeedbackInfo.mHasSoundFeedbackInfo = true;
- signalFeedbackInfo.mSoundFeedbackFile = GetSoundPath( *soundFeedbackFile );
- }
-
- if( signalFeedbackInfo.mHasHapticFeedbackInfo || signalFeedbackInfo.mHasSoundFeedbackInfo )
- {
- AddSignalInfo( themeInfo, signalFeedbackInfo );
- }
- }
-
- mStyleInfoLut[key] = themeInfo;
- }
-}
-
-void FeedbackController::AddSignalInfo( FeedbackStyleInfo& styleInfo, SignalFeedbackInfo signalInfo )
-{
- bool updated = false;
- std::vector<SignalFeedbackInfo>::iterator iter;
-
- // If info exists for the signal then update it, else add new
- for( iter = styleInfo.mSignalFeedbackInfoList.begin(); iter != styleInfo.mSignalFeedbackInfoList.end(); ++iter )
- {
- if( (*iter).mSignalName == signalInfo.mSignalName )
- {
- (*iter).mHasHapticFeedbackInfo = signalInfo.mHasHapticFeedbackInfo;
- (*iter).mHapticFeedbackPattern = signalInfo.mHapticFeedbackPattern;
- (*iter).mHapticFeedbackFile = signalInfo.mHapticFeedbackFile;
- (*iter).mHasSoundFeedbackInfo = signalInfo.mHasSoundFeedbackInfo;
- (*iter).mSoundFeedbackPattern = signalInfo.mSoundFeedbackPattern;
- (*iter).mSoundFeedbackFile = signalInfo.mSoundFeedbackFile;
-
- updated = true;
- break;
- }
- }
-
- if( !updated )
- {
- styleInfo.mSignalFeedbackInfoList.push_back( signalInfo );
- }
-}
-
-string FeedbackController::GetSoundPath( const string& key ) const
-{
- std::map<const string, const string>::const_iterator iter( mSoundFilesLut.find( key ) );
- string path;
- if( iter != mSoundFilesLut.end() )
- {
- path = iter->second;
- }
- else
- {
- DALI_LOG_WARNING( "Request for sound file '%s' failed\n", key.c_str() );
- DALI_ASSERT_ALWAYS( !"Sound file does not exist" );
- }
- return path;
-}
-
-string FeedbackController::GetHapticPath( const string& key ) const
-{
- std::map<const string, const string>::const_iterator iter( mHapticFilesLut.find( key ) );
- string path;
- if( iter != mHapticFilesLut.end() )
- {
- path = iter->second;
- }
- else
- {
- DALI_LOG_WARNING( "Request for haptic file '%s' failed\n", key.c_str() );
- DALI_ASSERT_ALWAYS( !"Haptic file does not exist" );
- }
- return path;
-}
-
-void FeedbackController::PlayFeedback(const string& type, const string& signalName)
-{
- const FeedbackStyleInfo styleInfo = GetStyleInfo(type);
- SignalFeedbackInfoConstIter iter;
-
- for(iter = styleInfo.mSignalFeedbackInfoList.begin(); iter != styleInfo.mSignalFeedbackInfoList.end(); ++iter)
- {
- const SignalFeedbackInfo& info = *iter;
-
- if(info.mSignalName == signalName)
- {
- if(info.mHasHapticFeedbackInfo)
- {
- if(!info.mHapticFeedbackPattern.empty())
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FeedbackController::PlayFeedback Playing Haptic effect: Object type: %s, Signal type: %s, pattern type: %s\n",
- type.c_str(), signalName.c_str(), info.mHapticFeedbackPattern.c_str());
-
- mPlugin.PlayFeedbackPattern( FEEDBACK_TYPE_VIBRATION, GetFeedbackPattern(info.mHapticFeedbackPattern) );
- }
- else if(!info.mHapticFeedbackFile.empty())
- {
- mPlugin.PlayHaptic( info.mHapticFeedbackFile );
- }
- }
-
- if(info.mHasSoundFeedbackInfo)
- {
- if(!info.mSoundFeedbackPattern.empty())
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FeedbackController::PlayFeedback Playing Sound effect: Object type: %s, Signal type: %s, pattern type: %s\n",
- type.c_str(), signalName.c_str(), info.mHapticFeedbackPattern.c_str());
-
- mPlugin.PlayFeedbackPattern( FEEDBACK_TYPE_SOUND, GetFeedbackPattern(info.mSoundFeedbackPattern) );
- }
- else if(!info.mSoundFeedbackFile.empty())
- {
- mPlugin.PlaySound( info.mSoundFeedbackFile );
- }
- }
-
- break;
- }
- }
-}
-
-FeedbackPattern FeedbackController::GetFeedbackPattern( const string &pattern )
-{
- if( 0 == mFeedbackPatternLut.size() )
- {
- mFeedbackPatternLut["FEEDBACK_PATTERN_NONE"] = Dali::FEEDBACK_PATTERN_NONE;
- mFeedbackPatternLut["FEEDBACK_PATTERN_TAP"] = Dali::FEEDBACK_PATTERN_TAP;
- mFeedbackPatternLut["FEEDBACK_PATTERN_SIP"] = Dali::FEEDBACK_PATTERN_SIP;
- mFeedbackPatternLut["FEEDBACK_PATTERN_SIP_BACKSPACE"] = Dali::FEEDBACK_PATTERN_SIP_BACKSPACE;
- mFeedbackPatternLut["FEEDBACK_PATTERN_MAX_CHARACTER"] = Dali::FEEDBACK_PATTERN_MAX_CHARACTER;
- mFeedbackPatternLut["FEEDBACK_PATTERN_KEY0"] = Dali::FEEDBACK_PATTERN_KEY0;
- mFeedbackPatternLut["FEEDBACK_PATTERN_KEY1"] = Dali::FEEDBACK_PATTERN_KEY1;
- mFeedbackPatternLut["FEEDBACK_PATTERN_KEY2"] = Dali::FEEDBACK_PATTERN_KEY2;
- mFeedbackPatternLut["FEEDBACK_PATTERN_KEY3"] = Dali::FEEDBACK_PATTERN_KEY3;
- mFeedbackPatternLut["FEEDBACK_PATTERN_KEY4"] = Dali::FEEDBACK_PATTERN_KEY4;
- mFeedbackPatternLut["FEEDBACK_PATTERN_KEY5"] = Dali::FEEDBACK_PATTERN_KEY5;
- mFeedbackPatternLut["FEEDBACK_PATTERN_KEY6"] = Dali::FEEDBACK_PATTERN_KEY6;
- mFeedbackPatternLut["FEEDBACK_PATTERN_KEY7"] = Dali::FEEDBACK_PATTERN_KEY7;
- mFeedbackPatternLut["FEEDBACK_PATTERN_KEY8"] = Dali::FEEDBACK_PATTERN_KEY8;
- mFeedbackPatternLut["FEEDBACK_PATTERN_KEY9"] = Dali::FEEDBACK_PATTERN_KEY9;
- mFeedbackPatternLut["FEEDBACK_PATTERN_KEY_STAR"] = Dali::FEEDBACK_PATTERN_KEY_STAR;
- mFeedbackPatternLut["FEEDBACK_PATTERN_KEY_SHARP"] = Dali::FEEDBACK_PATTERN_KEY_SHARP;
- mFeedbackPatternLut["FEEDBACK_PATTERN_HOLD"] = Dali::FEEDBACK_PATTERN_HOLD;
- mFeedbackPatternLut["FEEDBACK_PATTERN_MULTI_TAP"] = Dali::FEEDBACK_PATTERN_MULTI_TAP;
- mFeedbackPatternLut["FEEDBACK_PATTERN_HW_TAP"] = Dali::FEEDBACK_PATTERN_HW_TAP;
- mFeedbackPatternLut["FEEDBACK_PATTERN_HW_HOLD"] = Dali::FEEDBACK_PATTERN_HW_HOLD;
- mFeedbackPatternLut["FEEDBACK_PATTERN_MESSAGE"] = Dali::FEEDBACK_PATTERN_MESSAGE;
- mFeedbackPatternLut["FEEDBACK_PATTERN_MESSAGE_ON_CALL"] = Dali::FEEDBACK_PATTERN_MESSAGE_ON_CALL;
- mFeedbackPatternLut["FEEDBACK_PATTERN_EMAIL"] = Dali::FEEDBACK_PATTERN_EMAIL;
- mFeedbackPatternLut["FEEDBACK_PATTERN_EMAIL_ON_CALL"] = Dali::FEEDBACK_PATTERN_EMAIL_ON_CALL;
- mFeedbackPatternLut["FEEDBACK_PATTERN_WAKEUP"] = Dali::FEEDBACK_PATTERN_WAKEUP;
- mFeedbackPatternLut["FEEDBACK_PATTERN_WAKEUP_ON_CALL"] = Dali::FEEDBACK_PATTERN_WAKEUP_ON_CALL;
- mFeedbackPatternLut["FEEDBACK_PATTERN_SCHEDULE"] = Dali::FEEDBACK_PATTERN_SCHEDULE;
- mFeedbackPatternLut["FEEDBACK_PATTERN_SCHEDULE_ON_CALL"] = Dali::FEEDBACK_PATTERN_SCHEDULE_ON_CALL;
- mFeedbackPatternLut["FEEDBACK_PATTERN_TIMER"] = Dali::FEEDBACK_PATTERN_TIMER;
- mFeedbackPatternLut["FEEDBACK_PATTERN_TIMER_ON_CALL"] = Dali::FEEDBACK_PATTERN_TIMER_ON_CALL;
- mFeedbackPatternLut["FEEDBACK_PATTERN_GENERAL"] = Dali::FEEDBACK_PATTERN_GENERAL;
- mFeedbackPatternLut["FEEDBACK_PATTERN_GENERAL_ON_CALL"] = Dali::FEEDBACK_PATTERN_GENERAL_ON_CALL;
- mFeedbackPatternLut["FEEDBACK_PATTERN_POWERON"] = Dali::FEEDBACK_PATTERN_POWERON;
- mFeedbackPatternLut["FEEDBACK_PATTERN_POWEROFF"] = Dali::FEEDBACK_PATTERN_POWEROFF;
- mFeedbackPatternLut["FEEDBACK_PATTERN_CHARGERCONN"] = Dali::FEEDBACK_PATTERN_CHARGERCONN;
- mFeedbackPatternLut["FEEDBACK_PATTERN_CHARGERCONN_ON_CALL"] = Dali::FEEDBACK_PATTERN_CHARGERCONN_ON_CALL;
- mFeedbackPatternLut["FEEDBACK_PATTERN_FULLCHARGED"] = Dali::FEEDBACK_PATTERN_FULLCHARGED;
- mFeedbackPatternLut["FEEDBACK_PATTERN_FULLCHARGED_ON_CALL"] = Dali::FEEDBACK_PATTERN_FULLCHARGED_ON_CALL;
- mFeedbackPatternLut["FEEDBACK_PATTERN_LOWBATT"] = Dali::FEEDBACK_PATTERN_LOWBATT;
- mFeedbackPatternLut["FEEDBACK_PATTERN_LOWBATT_ON_CALL"] = Dali::FEEDBACK_PATTERN_LOWBATT_ON_CALL;
- mFeedbackPatternLut["FEEDBACK_PATTERN_LOCK"] = Dali::FEEDBACK_PATTERN_LOCK;
- mFeedbackPatternLut["FEEDBACK_PATTERN_UNLOCK"] = Dali::FEEDBACK_PATTERN_UNLOCK;
- mFeedbackPatternLut["FEEDBACK_PATTERN_CALLCONNECT"] = Dali::FEEDBACK_PATTERN_CALLCONNECT;
- mFeedbackPatternLut["FEEDBACK_PATTERN_DISCALLCONNECT"] = Dali::FEEDBACK_PATTERN_DISCALLCONNECT;
- mFeedbackPatternLut["FEEDBACK_PATTERN_MINUTEMINDER"] = Dali::FEEDBACK_PATTERN_MINUTEMINDER;
- mFeedbackPatternLut["FEEDBACK_PATTERN_VIBRATION"] = Dali::FEEDBACK_PATTERN_VIBRATION;
- mFeedbackPatternLut["FEEDBACK_PATTERN_SHUTTER"] = Dali::FEEDBACK_PATTERN_SHUTTER;
- mFeedbackPatternLut["FEEDBACK_PATTERN_LIST_REORDER"] = Dali::FEEDBACK_PATTERN_LIST_REORDER;
- mFeedbackPatternLut["FEEDBACK_PATTERN_SLIDER_SWEEP"] = Dali::FEEDBACK_PATTERN_SLIDER_SWEEP;
- }
-
- std::map<const string, FeedbackPattern>::const_iterator iter( mFeedbackPatternLut.find( pattern ) );
-
- if( iter != mFeedbackPatternLut.end() )
- {
- return iter->second;
- }
- else
- {
- DALI_LOG_ERROR( "Unknown feedback pattern type: %s, So Defaulting to FEEDBACK_PATTERN_NONE!\n" );
- return Dali::FEEDBACK_PATTERN_NONE;
- }
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_FEEDBACK_CONTROLLER_H__
-#define __DALI_INTERNAL_FEEDBACK_CONTROLLER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <map>
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/adaptor-framework/common/style-monitor.h>
-
-// INTERNAL INCLUDES
-#include <public-api/adaptor-framework/common/feedback-plugin.h>
-#include <internal/common/feedback/feedback-ids.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-struct FeedbackStyleInfo;
-struct SignalFeedbackInfo;
-
-class FeedbackPluginProxy;
-
-/**
- * Plays feedback effects for Dali-Toolkit UI Controls.
- */
-class FeedbackController : public ConnectionTracker
-{
-public:
-
- /**
- * Constructor.
- */
- FeedbackController( FeedbackPluginProxy& plugin );
-
- /**
- * The destructor
- */
- ~FeedbackController();
-
- /**
- * Called to start playing feedback effects.
- */
- void Start();
-
- /**
- * Called to stop playing feedback effects.
- */
- void Stop();
-
- /**
- * Callback function to play a feedback effect when a signal is emitted for an object
- * Plays feedback effect.
- * @param [in] type The Object type
- * @param [in] signalName The name of the signal
- */
- void PlayFeedback(const std::string& type, const std::string& signalName);
-
-private:
-
- /**
- * UI string data format
- */
- enum UIFormat
- {
- JSON, ///< String is JSON
- };
-
- /**
- * Callback function for Dali::ObjectRegistry::SignalObjectCreated signal
- * @param [in] object Handle to the newly created object
- */
- void ObjectCreatedCallback( BaseHandle object );
-
- /**
- * Helper to retrieve styleInfo from mStyleInfoLut
- * @param type A string described a type of object
- * @return The style information for the given object
- */
- const FeedbackStyleInfo& GetStyleInfo( const std::string& type) const;
-
- /**
- * Callback function for Dali::ObjectRegistry::SignalObjectCreated signal
- * @param [in] object Handle to the newly created object
- */
- void StyleChangedCallback(Dali::StyleMonitor styleMonitor, StyleChange styleChange);
-
- /**
- * Callback function for Dali::Toolkit::PushButton::SignalPressed signal
- * Plays feedback effect.
- * @param [in] effect The feedback effect to play
- */
- bool LoadTheme(const std::string& data);
-
- /**
- * Loads a string representation the theme.
- * @param [in] data A string represenation of the theme.
- * @param [in] format The string representation format ie JSON.
- */
- void LoadFromString( const std::string& data );
-
- /**
- * Helper to store signal information.
- * @param [in] styleInfo The information will be stored here.
- * @param [in] signalInfo The information to add.
- */
- void AddSignalInfo( FeedbackStyleInfo& styleInfo, SignalFeedbackInfo signalInfo );
-
- /**
- * Helper to retrieve the path to a sound file.
- * @param[in] key A string which identifies the path.
- * @return The path.
- */
- std::string GetSoundPath( const std::string& key ) const;
-
- /**
- * Helper to retrieve the path to a haptic file.
- * @param[in] key A string which identifies the path.
- * @return The path.
- */
- std::string GetHapticPath( const std::string& key ) const;
-
- /**
- * Map a pattern string to feedback pattern ID.
- * @param [in] pattern The pattern string.
- * @return A feedback pattern ID.
- */
- FeedbackPattern GetFeedbackPattern( const std::string& pattern );
-
- /**
- * Plays a feedback effect
- * @param [in] type The feedback type haptic or sound
- * @param [in] effect The feedback effect to play
- */
- void PlayEffect(FeedbackType type, FeedbackPattern effect);
-
- /**
- * Plays a haptic or sound effect file
- * @param [in] type The feedback type haptic or sound
- * @param [in] file The path to the file containing the effect
- */
- void PlayFile(FeedbackType type, const std::string& file);
-
-private:
-
- FeedbackPluginProxy& mPlugin;
-
- std::map<const std::string, FeedbackPattern> mFeedbackPatternLut; ///< Used to convert feedback pattern strings into enumerated values
- std::map<const std::string, const std::string> mSoundFilesLut; ///< Converts key strings into sound file paths
- std::map<const std::string, const std::string> mHapticFilesLut; ///< Converts key strings into haptic file paths
- std::map<const std::string, FeedbackStyleInfo> mStyleInfoLut; ///< Converts key strings into style information
-
- SlotDelegate< FeedbackController > mConnections; ///< Maintains the connections to the Object registry.
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_FEEDBACK_CONTROLLER_H__
+++ /dev/null
-#ifndef __DALI_FEEDBACK_IDS_H__
-#define __DALI_FEEDBACK_IDS_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-namespace Dali
-{
-
-/**
- * Enumerations for the types of feedback
- * Note: These are based on feedback_type_e in libsvi
- */
-enum FeedbackType
-{
- FEEDBACK_TYPE_NONE,
-
- FEEDBACK_TYPE_SOUND,
- FEEDBACK_TYPE_VIBRATION,
- FEEDBACK_TYPE_LED,
-
- FEEDBACK_TYPE_END
-};
-
-/**
- * The pattern list for feedback effects.
- * Note: These are based on feedback_pattern_e in libsvi
- */
-enum FeedbackPattern
-{
- FEEDBACK_PATTERN_NONE = -1,
-
- FEEDBACK_PATTERN_TAP = 0, /**< feedback pattern when general touch */
- FEEDBACK_PATTERN_SIP, /**< feedback pattern when touch text key */
- FEEDBACK_PATTERN_SIP_BACKSPACE, /**< feedback pattern when touch backspace key */
- FEEDBACK_PATTERN_MAX_CHARACTER, /**< feedback pattern when max character */
- FEEDBACK_PATTERN_KEY0, /**< feedback pattern when touch numeric 0 key */
- FEEDBACK_PATTERN_KEY1, /**< feedback pattern when touch numeric 1 key */
- FEEDBACK_PATTERN_KEY2, /**< feedback pattern when touch numeric 2 key */
- FEEDBACK_PATTERN_KEY3, /**< feedback pattern when touch numeric 3 key */
- FEEDBACK_PATTERN_KEY4, /**< feedback pattern when touch numeric 4 key */
- FEEDBACK_PATTERN_KEY5, /**< feedback pattern when touch numeric 5 key */
- FEEDBACK_PATTERN_KEY6, /**< feedback pattern when touch numeric 6 key */
- FEEDBACK_PATTERN_KEY7, /**< feedback pattern when touch numeric 7 key */
- FEEDBACK_PATTERN_KEY8, /**< feedback pattern when touch numeric 8 key */
- FEEDBACK_PATTERN_KEY9, /**< feedback pattern when touch numeric 9 key */
- FEEDBACK_PATTERN_KEY_STAR, /**< feedback pattern when touch star key */
- FEEDBACK_PATTERN_KEY_SHARP, /**< feedback pattern when touch sharp key */
- FEEDBACK_PATTERN_HOLD, /**< feedback pattern when touch hold */
- FEEDBACK_PATTERN_MULTI_TAP, /**< feedback pattern when multi touch */
- FEEDBACK_PATTERN_HW_TAP, /**< feedback pattern when press hardware key */
- FEEDBACK_PATTERN_HW_HOLD, /**< feedback pattern when holding press hardware key */
-
- FEEDBACK_PATTERN_MESSAGE, /**< feedback pattern when incoming a message */
- FEEDBACK_PATTERN_MESSAGE_ON_CALL, /**< feedback pattern when incoming a message on call */
- FEEDBACK_PATTERN_EMAIL, /**< feedback pattern when incoming an email */
- FEEDBACK_PATTERN_EMAIL_ON_CALL, /**< feedback pattern when incoming an email on call */
- FEEDBACK_PATTERN_WAKEUP, /**< feedback pattern when alert wake up call */
- FEEDBACK_PATTERN_WAKEUP_ON_CALL, /**< feedback pattern when alert wake up call on call */
- FEEDBACK_PATTERN_SCHEDULE, /**< feedback pattern when alert schedule alarm */
- FEEDBACK_PATTERN_SCHEDULE_ON_CALL, /**< feedback pattern when alert schedule alarm on call */
- FEEDBACK_PATTERN_TIMER, /**< feedback pattern when alert timer */
- FEEDBACK_PATTERN_TIMER_ON_CALL, /**< feedback pattern when alert timer on call */
- FEEDBACK_PATTERN_GENERAL, /**< feedback pattern when alert general event */
- FEEDBACK_PATTERN_GENERAL_ON_CALL, /**< feedback pattern when alert general event on call */
-
- FEEDBACK_PATTERN_POWERON, /**< feedback pattern when power on */
- FEEDBACK_PATTERN_POWEROFF, /**< feedback pattern when power off */
- FEEDBACK_PATTERN_CHARGERCONN, /**< feedback pattern when connecting charger */
- FEEDBACK_PATTERN_CHARGERCONN_ON_CALL, /**< feedback pattern when connecting charger on call */
- FEEDBACK_PATTERN_FULLCHARGED, /**< feedback pattern when full charged */
- FEEDBACK_PATTERN_FULLCHARGED_ON_CALL, /**< feedback pattern when full charged on call */
- FEEDBACK_PATTERN_LOWBATT, /**< feedback pattern when low battery */
- FEEDBACK_PATTERN_LOWBATT_ON_CALL, /**< feedback pattern when low battery on call */
- FEEDBACK_PATTERN_LOCK, /**< feedback pattern when lock */
- FEEDBACK_PATTERN_UNLOCK, /**< feedback pattern when unlock */
- FEEDBACK_PATTERN_CALLCONNECT, /**< feedback pattern when connecting call */
- FEEDBACK_PATTERN_DISCALLCONNECT, /**< feedback pattern when disconnecting call */
- FEEDBACK_PATTERN_MINUTEMINDER, /**< feedback pattern when minute minder */
- FEEDBACK_PATTERN_VIBRATION, /**< feedback pattern when vibration */
- FEEDBACK_PATTERN_SHUTTER, /**< feedback pattern when screen capture or camera shutter */
- FEEDBACK_PATTERN_LIST_REORDER, /**< feedback pattern when list reorder */
- FEEDBACK_PATTERN_SLIDER_SWEEP, /**< feedback pattern when slider sweep */
-
- FEEDBACK_PATTERN_END,
-};
-
-
-} // namespace Dali
-
-#endif // __DALI_FEEDBACK_IDS_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <internal/common/feedback/feedback-plugin-proxy.h>
-
-// EXTERNAL INCLUDES
-#include <dlfcn.h>
-#include <dali/integration-api/debug.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-const char * const FeedbackPluginProxy::DEFAULT_OBJECT_NAME( "libdali-feedback-plugin.so" );
-
-FeedbackPluginProxy::FeedbackPluginProxy( const std::string& sharedObjectName )
-: mInitializeAttempted( false ),
- mLibHandle( NULL ),
- mSharedObjectName( sharedObjectName ),
- mCreatePluginFunctionPtr( NULL ),
- mFeedbackPlugin( NULL )
-{
- // Lazily initialize when sound/haptic is first played
-}
-
-FeedbackPluginProxy::~FeedbackPluginProxy()
-{
- if( mFeedbackPlugin )
- {
- delete mFeedbackPlugin;
- mFeedbackPlugin = NULL;
-
- DALI_ASSERT_ALWAYS( mLibHandle );
- if( dlclose( mLibHandle ) )
- {
- DALI_LOG_ERROR( "Error closing dali feedback plugin library: %s\n", dlerror() );
- }
- }
-}
-
-void FeedbackPluginProxy::PlayHaptic( const std::string& filePath )
-{
- // Lazy initialization
- Initialize();
-
- if( mFeedbackPlugin )
- {
- mFeedbackPlugin->PlayHaptic( filePath );
- }
-}
-
-void FeedbackPluginProxy::PlayHapticMonotone( unsigned int duration )
-{
- // Lazy initialization
- Initialize();
-
- if( mFeedbackPlugin )
- {
- mFeedbackPlugin->PlayHapticMonotone( duration );
- }
-}
-
-void FeedbackPluginProxy::StopHaptic()
-{
- // Must already have been initialized to play haptic
- if( mFeedbackPlugin )
- {
- mFeedbackPlugin->StopHaptic();
- }
-}
-
-int FeedbackPluginProxy::PlaySound( const std::string& fileName )
-{
- // Lazy initialization
- Initialize();
-
- if( mFeedbackPlugin )
- {
- return mFeedbackPlugin->PlaySound( fileName );
- }
-
- return 0;
-}
-
-void FeedbackPluginProxy::StopSound( int handle )
-{
- // Must already have been initialized to play sound
- if ( mFeedbackPlugin )
- {
- mFeedbackPlugin->StopSound( handle );
- }
-}
-
-void FeedbackPluginProxy::PlayFeedbackPattern( int type, int pattern )
-{
- // Lazy initialization
- Initialize();
-
- if( mFeedbackPlugin )
- {
- mFeedbackPlugin->PlayFeedbackPattern( type, pattern );
- }
-}
-
-void FeedbackPluginProxy::Initialize()
-{
- // Only attempt to load dll once
- if ( !mInitializeAttempted )
- {
- mInitializeAttempted = true;
-
- mLibHandle = dlopen( mSharedObjectName.c_str(), RTLD_NOW | RTLD_GLOBAL );
- if( !mLibHandle )
- {
- DALI_LOG_ERROR( "Cannot load dali feedback plugin library error: %s\n", dlerror() );
- return;
- }
-
- // reset errors
- dlerror();
-
- // load plugin
- mCreatePluginFunctionPtr = reinterpret_cast<CreateFeedbackPlugin*>(dlsym(mLibHandle, "CreateFeedbackPlugin"));
- if(!mCreatePluginFunctionPtr)
- {
- DALI_LOG_ERROR("Cannot load symbol CreateFeedbackPlugin(): %s\n", dlerror());
- return;
- }
-
- // reset errors
- dlerror();
-
- mFeedbackPlugin = mCreatePluginFunctionPtr();
-
- if(!mFeedbackPlugin)
- {
- DALI_LOG_ERROR("Call to function CreateFeedbackPlugin() failed\n");
- }
- }
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_FEEDBACK_PLUGIN_PROXY_H__
-#define __DALI_INTERNAL_FEEDBACK_PLUGIN_PROXY_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <public-api/adaptor-framework/common/feedback-plugin.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-typedef Dali::FeedbackPlugin::SoundStopCallBack SoundStopCallBack;
-typedef Dali::FeedbackPlugin::CreateFeedbackPlugin CreateFeedbackPlugin;
-
-/**
- * Proxy class to dynamically load, use and unload feedback plugin.
- */
-class FeedbackPluginProxy
-{
-public:
-
- /**
- * The default feedback plugin proxy.
- */
- static const char * const DEFAULT_OBJECT_NAME;
-
-public:
-
- /**
- * Constructor.
- */
- FeedbackPluginProxy( const std::string& sharedObjectName );
-
- /**
- * The destructor
- */
- ~FeedbackPluginProxy();
-
- /**
- * @copydoc Dali::Integration::FeedbackPlugin::PlayHaptic()
- */
- void PlayHaptic( const std::string& filePath );
-
- /**
- * @copydoc Dali::FeedbackPlugin::PlayHapticMonotone()
- */
- void PlayHapticMonotone( unsigned int duration );
-
- /**
- * @copydoc Dali::FeedbackPlugin::StopHaptic()
- */
- void StopHaptic();
-
- /**
- * @copydoc Dali::FeedbackPlugin::PlaySound()
- */
- int PlaySound( const std::string& fileName );
-
- /**
- * @copydoc Dali::FeedbackPlugin::StopSound()
- */
- void StopSound( int handle );
-
- /**
- * @copydoc Dali::FeedbackPlugin::PlayFeedbackPattern()
- */
- void PlayFeedbackPattern( int type, int pattern );
-
-private:
-
- /**
- * Dynamically loads the feedback plugin.
- */
- void Initialize();
-
-private:
-
- bool mInitializeAttempted;
- void* mLibHandle;
- std::string mSharedObjectName;
- CreateFeedbackPlugin* mCreatePluginFunctionPtr;
- Dali::FeedbackPlugin* mFeedbackPlugin;
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_FEEDBACK_PLUGIN_PROXY_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "file-descriptor-monitor.h"
-
-// EXTERNAL INCLUDES
-#include <Ecore.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Using Impl to hide away EFL specific members
- */
-struct FileDescriptorMonitor::Impl
-{
- // Construction
- Impl(int fileDescriptor, boost::function<void()> functor)
- : mFileDescriptor(fileDescriptor),
- mFunctor(functor),
- mHandler(NULL)
- {
- }
-
- // Data
- int mFileDescriptor;
- boost::function<void()> mFunctor;
- Ecore_Fd_Handler* mHandler;
-
- // Static Methods
-
- /**
- * Called when the file descriptor receives an event.
- */
- static Eina_Bool EventDispatch(void* data, Ecore_Fd_Handler *handler)
- {
- Impl* impl = reinterpret_cast<Impl*>(data);
-
- impl->mFunctor();
-
- return ECORE_CALLBACK_RENEW;
- }
-};
-
-FileDescriptorMonitor::FileDescriptorMonitor(int fileDescriptor, boost::function<void()> functor)
-{
- mImpl = new Impl(fileDescriptor, functor);
-
- if (fileDescriptor >= 0)
- {
- mImpl->mHandler = ecore_main_fd_handler_add(fileDescriptor, ECORE_FD_READ, &Impl::EventDispatch, mImpl, NULL, NULL);
- }
-}
-
-FileDescriptorMonitor::~FileDescriptorMonitor()
-{
- if (mImpl->mHandler)
- {
- ecore_main_fd_handler_del(mImpl->mHandler);
- }
-
- delete mImpl;
- mImpl = NULL;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_FILE_DESCRIPTOR_MONITOR_H__
-#define __DALI_INTERNAL_FILE_DESCRIPTOR_MONITOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-
-namespace Dali
-{
-
-namespace Integration
-{
-class Core;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Monitors the given file descriptor and whenever anything is written to it, it calls
- * the given boost function.
- */
-class FileDescriptorMonitor
-{
-public:
-
- /**
- * Constructor
- * @param[in] fileDescriptor The file descriptor to monitor
- * @param[in] functor The function to call when anything is written to the file descriptor
- */
- FileDescriptorMonitor(int fileDescriptor, boost::function<void()> functor);
-
- /**
- * Destructor
- */
- ~FileDescriptorMonitor();
-
-private:
- struct Impl;
- Impl* mImpl;
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_FILE_DESCRIPTOR_MONITOR_H__
+++ /dev/null
-# Add local source files here
-
-tizen_adaptor_internal_common_src_files = \
- $(tizen_adaptor_internal_src_dir)/accessibility-gesture-detector.cpp \
- $(tizen_adaptor_internal_src_dir)/accessibility-manager-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/adaptor-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/clipboard-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/clipboard-event-notifier-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/drag-and-drop-detector-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/ecore-callback-manager.cpp \
- $(tizen_adaptor_internal_src_dir)/file-descriptor-monitor.cpp \
- $(tizen_adaptor_internal_src_dir)/haptic-player-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/imf-manager-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/indicator-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/indicator-buffer.cpp \
- $(tizen_adaptor_internal_src_dir)/kernel-trace.cpp \
- $(tizen_adaptor_internal_src_dir)/locale-utils.cpp \
- $(tizen_adaptor_internal_src_dir)/native-bitmap-buffer-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/object-profiler.cpp \
- $(tizen_adaptor_internal_src_dir)/orientation-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/physical-keyboard-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/pixmap-image-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/render-surface-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/server-connection.cpp \
- $(tizen_adaptor_internal_src_dir)/shared-file.cpp \
- $(tizen_adaptor_internal_src_dir)/sound-player-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/style-monitor-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/tilt-sensor-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/timer-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/trigger-event.cpp \
- $(tizen_adaptor_internal_src_dir)/trigger-event-factory.cpp \
- $(tizen_adaptor_internal_src_dir)/tts-player-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/virtual-keyboard-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/vsync-monitor.cpp \
- $(tizen_adaptor_internal_src_dir)/window-impl.cpp \
- \
- $(tizen_adaptor_internal_src_dir)/events/event-handler.cpp \
- $(tizen_adaptor_internal_src_dir)/events/gesture-manager.cpp \
- $(tizen_adaptor_internal_src_dir)/events/long-press-gesture-detector.cpp \
- $(tizen_adaptor_internal_src_dir)/events/pan-gesture-detector-base.cpp \
- $(tizen_adaptor_internal_src_dir)/events/pan-gesture-detector.cpp \
- $(tizen_adaptor_internal_src_dir)/events/pinch-gesture-detector.cpp \
- $(tizen_adaptor_internal_src_dir)/events/tap-gesture-detector.cpp \
- \
- $(tizen_adaptor_internal_src_dir)/feedback/feedback-controller.cpp \
- $(tizen_adaptor_internal_src_dir)/feedback/feedback-plugin-proxy.cpp \
- \
- $(tizen_adaptor_internal_src_dir)/gl/egl-factory.cpp \
- $(tizen_adaptor_internal_src_dir)/gl/egl-image-extensions.cpp \
- $(tizen_adaptor_internal_src_dir)/gl/egl-implementation.cpp \
- $(tizen_adaptor_internal_src_dir)/gl/egl-sync-implementation.cpp \
- $(tizen_adaptor_internal_src_dir)/gl/gl-proxy-implementation.cpp \
- $(tizen_adaptor_internal_src_dir)/gl/gl-extensions.cpp \
- \
- $(tizen_adaptor_internal_src_dir)/ecore-x/pixmap-render-surface.cpp \
- $(tizen_adaptor_internal_src_dir)/ecore-x/ecore-x-render-surface.cpp \
- $(tizen_adaptor_internal_src_dir)/ecore-x/window-render-surface.cpp \
- $(tizen_adaptor_internal_src_dir)/ecore-x/ecore-x-window-interface.cpp
-
-tizen_adaptor_internal_common_profile_src_files = \
- $(tizen_adaptor_internal_src_dir)/key-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/system-settings.cpp \
- $(tizen_adaptor_internal_src_dir)/color-controller-impl.cpp \
- \
- $(tizen_adaptor_internal_src_dir)/ecore-x/ecore-x-render-surface-factory.cpp
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "egl-factory.h"
-
-// INTERNAL INCLUDES
-#include <internal/common/gl/egl-implementation.h>
-#include <internal/common/gl/egl-image-extensions.h>
-#include <internal/common/gl/egl-sync-implementation.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-EglFactory::EglFactory()
-: mEglImplementation(NULL),
- mEglImageExtensions(NULL),
- mEglSync(new EglSyncImplementation) // Created early, as needed by Core constructor
-{
-}
-
-EglFactory::~EglFactory()
-{
- // Ensure the EGL implementation is destroyed
- delete mEglImageExtensions;
- delete mEglImplementation;
- delete mEglSync;
-}
-
-EglInterface* EglFactory::Create()
-{
- // Created by RenderThread (After Core construction)
- mEglImplementation = new EglImplementation();
- mEglImageExtensions = new EglImageExtensions(mEglImplementation);
-
- mEglSync->Initialize(mEglImplementation); // The sync impl needs the EglDisplay
- return mEglImplementation;
-}
-
-void EglFactory::Destroy()
-{
- delete mEglImageExtensions;
- mEglImageExtensions = NULL;
- delete mEglImplementation;
- mEglImplementation = NULL;
-}
-
-EglInterface* EglFactory::GetImplementation()
-{
- return mEglImplementation;
-}
-
-EglImageExtensions* EglFactory::GetImageExtensions()
-{
- return mEglImageExtensions;
-}
-
-EglSyncImplementation* EglFactory::GetSyncImplementation()
-{
- return mEglSync;
-}
-
-} // Adaptor
-} // Internal
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H__
-#define __DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-
-// INTERNAL INCLUDES
-#include <base/interfaces/egl-factory-interface.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-class EglImplementation;
-class EglImageExtensions;
-class EglSyncImplementation;
-
-class EglFactory : public EglFactoryInterface
-{
-public:
- /**
- * Constructor
- */
- EglFactory();
-
- /**
- * Destructor
- */
- virtual ~EglFactory();
-
- /**
- * Create an EGL Implementation
- * @return[in] An implementation
- */
- EglInterface* Create();
-
- /**
- * Destroy the EGL Implementation
- */
- void Destroy();
-
- /**
- * Get an implementation if one has been created.
- * @return An implementation, or NULL if one has not yet been created.
- */
- EglInterface* GetImplementation();
-
- /**
- * Get the image extension
- */
- EglImageExtensions* GetImageExtensions();
-
- /**
- * Get the fence sync implementation
- * @return An implementation of fence sync
- */
- EglSyncImplementation* GetSyncImplementation();
-
-private:
- /** Undefined */
- EglFactory(const EglFactory& rhs);
- EglFactory& operator=(const EglFactory& rhs);
-
-private:
- EglImplementation* mEglImplementation;
- EglImageExtensions* mEglImageExtensions;
- EglSyncImplementation* mEglSync;
-};
-
-}
-}
-}
-
-#endif //__DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-// CLASS HEADER
-#include "egl-image-extensions.h"
-
-// EXTERNAL INCLUDES
-#if DALI_GLES_VERSION >= 30
-#include <GLES3/gl3.h>
-#include <GLES3/gl3ext.h>
-
-#else
-#include <GLES2/gl2.h>
-#endif // DALI_GLES_VERSION >= 30
-
-#include <GLES2/gl2ext.h>
-
-#include <EGL/eglext.h>
-
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/gl/egl-implementation.h>
-
-
-namespace
-{
-// function pointers assigned in InitializeEglImageKHR
-PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = 0;
-PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = 0;
-PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES = 0;
-} // unnamed namespace
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-EglImageExtensions::EglImageExtensions(EglImplementation* eglImpl)
-: mEglImplementation(eglImpl),
- mImageKHRInitialized(false),
- mImageKHRInitializeFailed(false)
-{
- DALI_ASSERT_ALWAYS( eglImpl && "EGL Implementation not instantiated" );
-}
-
-EglImageExtensions::~EglImageExtensions()
-{
-}
-
-void* EglImageExtensions::CreateImageKHR(EGLClientBuffer pixmap)
-{
- if (mImageKHRInitialized == false)
- {
- InitializeEglImageKHR();
- }
-
- if (mImageKHRInitialized == false)
- {
- return NULL;
- }
-
- // Use the EGL image extension
- const EGLint attribs[] =
- {
- EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
- EGL_NONE
- };
-
- EGLImageKHR eglImage = eglCreateImageKHR( mEglImplementation->GetDisplay(),
- EGL_NO_CONTEXT,
- EGL_NATIVE_PIXMAP_KHR,
- pixmap,
- attribs );
-
- DALI_ASSERT_DEBUG( EGL_NO_IMAGE_KHR != eglImage && "X11Image::GlExtensionCreate eglCreateImageKHR failed!\n");
- if( EGL_NO_IMAGE_KHR != eglImage )
- {
- switch( eglGetError() )
- {
- case EGL_SUCCESS :
- {
- break;
- }
- case EGL_BAD_DISPLAY:
- {
- DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object" );
- break;
- }
- case EGL_BAD_CONTEXT:
- {
- DALI_LOG_ERROR( "EGL_BAD_CONTEXT: Invalid EGLContext object" );
- break;
- }
- case EGL_BAD_PARAMETER:
- {
- DALI_LOG_ERROR( "EGL_BAD_PARAMETER: Invalid target parameter or attribute in attrib_list" );
- break;
- }
- case EGL_BAD_MATCH:
- {
- DALI_LOG_ERROR( "EGL_BAD_MATCH: attrib_list does not match target" );
- break;
- }
- case EGL_BAD_ACCESS:
- {
- DALI_LOG_ERROR( "EGL_BAD_ACCESS: Previously bound off-screen, or EGLImage sibling error" );
- break;
- }
- case EGL_BAD_ALLOC:
- {
- DALI_LOG_ERROR( "EGL_BAD_ALLOC: Insufficient memory is available" );
- break;
- }
- default:
- {
- break;
- }
- }
- }
-
- return (void*)eglImage;
-}
-
-void EglImageExtensions::DestroyImageKHR(void* eglImageKHR)
-{
- DALI_ASSERT_DEBUG( mImageKHRInitialized );
-
- if( ! mImageKHRInitialized )
- {
- return;
- }
-
- if( eglImageKHR == NULL )
- {
- return;
- }
-
- EGLImageKHR eglImage = static_cast<EGLImageKHR>(eglImageKHR);
-
- EGLBoolean result = eglDestroyImageKHR(mEglImplementation->GetDisplay(), eglImage);
-
- if( EGL_FALSE == result )
- {
- switch( eglGetError() )
- {
- case EGL_BAD_DISPLAY:
- {
- DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object" );
- break;
- }
- case EGL_BAD_PARAMETER:
- {
- DALI_LOG_ERROR( "EGL_BAD_PARAMETER: eglImage is not a valid EGLImageKHR object created with respect to EGLDisplay" );
- break;
- }
- case EGL_BAD_ACCESS:
- {
- DALI_LOG_ERROR( "EGL_BAD_ACCESS: EGLImage sibling error" );
- break;
- }
- default:
- {
- break;
- }
- }
- }
-}
-
-void EglImageExtensions::TargetTextureKHR(void* eglImageKHR)
-{
- DALI_ASSERT_DEBUG( mImageKHRInitialized );
-
- if( eglImageKHR != NULL )
- {
- EGLImageKHR eglImage = static_cast<EGLImageKHR>(eglImageKHR);
-
-#ifdef EGL_ERROR_CHECKING
- GLint glError = glGetError();
-#endif
-
- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)eglImage);
-
-#ifdef EGL_ERROR_CHECKING
- glError = glGetError();
- if( GL_NO_ERROR != glError )
- {
- DALI_LOG_ERROR(" glEGLImageTargetTexture2DOES returned error %0x04x\n", glError );
- }
-#endif
- }
-}
-
-void EglImageExtensions::InitializeEglImageKHR()
-{
- // avoid trying to reload extended KHR functions, if it fails the first time
- if( ! mImageKHRInitializeFailed )
- {
- eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress("eglCreateImageKHR"); /* parasoft-suppress MISRA2004-11_1_DMC "Using EGL defined functions." */
- eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) eglGetProcAddress("eglDestroyImageKHR"); /* parasoft-suppress MISRA2004-11_1_DMC "Using EGL defined functions." */
- glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) eglGetProcAddress("glEGLImageTargetTexture2DOES"); /* parasoft-suppress MISRA2004-11_1_DMC "Using EGL defined functions." */
- }
-
- if (eglCreateImageKHR && eglDestroyImageKHR && glEGLImageTargetTexture2DOES)
- {
- mImageKHRInitialized = true;
- }
- else
- {
- mImageKHRInitializeFailed = true;
- }
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_EGL_IMAGE_EXTENSIONS_H__
-#define __DALI_INTERNAL_EGL_IMAGE_EXTENSIONS_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <EGL/egl.h>
-
-#include <dali/public-api/images/pixel.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-class EglImplementation;
-
-/**
- * EglImageExtensions class provides EGL image extension support
- */
-class EglImageExtensions
-{
-public:
- /**
- * Constructor
- */
- EglImageExtensions(EglImplementation* impl);
-
- /**
- * Destructor
- */
- ~EglImageExtensions();
-
-
-public: // EGLImageKHR extension support
-
- /**
- * If the EGL Image extension is available this function returns a
- * EGLImageKHR
- * @param pixmap The pixmap
- * @return an object that holds a EGLImageKHR
- */
- void* CreateImageKHR(EGLClientBuffer pixmap);
-
- /**
- * If the EGL Image extension is available this function
- * destroys the a EGLImageKHR
- * @param eglImageKHR Object that holds a EGLImageKHR
- */
- void DestroyImageKHR(void* eglImageKHR);
-
- /**
- * defines a 2D texture
- * @param eglImageKHR Object that holds a EGLImageKHR
- */
- void TargetTextureKHR(void* eglImageKHR);
-
- /**
- * Get the functions for using ImageKHR
- */
- void InitializeEglImageKHR();
-
-private:
- EglImplementation* mEglImplementation;
-
- bool mImageKHRInitialized; ///< Flag for whether extended KHR functions loaded
- bool mImageKHRInitializeFailed; ///< Flag to avoid trying to reload extended KHR functions, if
- /// it fails the first time
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_EGL_IMAGE_EXTENSIONS_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-// CLASS HEADER
-#include "egl-implementation.h"
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/common/dali-vector.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/ecore-x/ecore-x-render-surface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-#define TEST_EGL_ERROR(lastCommand) \
-{ \
- EGLint err = eglGetError(); \
- if (err != EGL_SUCCESS) \
- { \
- DALI_LOG_ERROR("EGL error after %s code=%d\n", lastCommand,err); \
- DALI_ASSERT_ALWAYS(0 && "EGL error"); \
- } \
-}
-
-EglImplementation::EglImplementation()
- : mEglNativeDisplay(0),
- mEglNativeWindow(0),
- mEglNativePixmap(0),
- mEglDisplay(0),
- mEglConfig(0),
- mEglContext(0),
- mEglSurface(0),
- mGlesInitialized(false),
- mIsOwnSurface(true),
- mSyncMode(FULL_SYNC),
- mContextCurrent(false),
- mIsWindow(true),
- mColorDepth(COLOR_DEPTH_24)
-{
-}
-
-EglImplementation::~EglImplementation()
-{
- TerminateGles();
-}
-
-bool EglImplementation::InitializeGles( EGLNativeDisplayType display, bool isOwnSurface )
-{
- if ( !mGlesInitialized )
- {
- mEglNativeDisplay = display;
-
- //@todo see if we can just EGL_DEFAULT_DISPLAY instead
- mEglDisplay = eglGetDisplay(mEglNativeDisplay);
-
- EGLint majorVersion = 0;
- EGLint minorVersion = 0;
- if ( !eglInitialize( mEglDisplay, &majorVersion, &minorVersion ) )
- {
- return false;
- }
- eglBindAPI(EGL_OPENGL_ES_API);
-
- mContextAttribs.Clear();
-
-#if DALI_GLES_VERSION >= 30
-
- mContextAttribs.Reserve(5);
- mContextAttribs.PushBack( EGL_CONTEXT_MAJOR_VERSION_KHR );
- mContextAttribs.PushBack( 3 );
- mContextAttribs.PushBack( EGL_CONTEXT_MINOR_VERSION_KHR );
- mContextAttribs.PushBack( 0 );
-
-#else // DALI_GLES_VERSION >= 30
-
- mContextAttribs.Reserve(3);
- mContextAttribs.PushBack( EGL_CONTEXT_CLIENT_VERSION );
- mContextAttribs.PushBack( 2 );
-
-#endif // DALI_GLES_VERSION >= 30
-
- mContextAttribs.PushBack( EGL_NONE );
-
- mGlesInitialized = true;
- mIsOwnSurface = isOwnSurface;
- }
-
- return mGlesInitialized;
-}
-
-bool EglImplementation::CreateContext()
-{
- // make sure a context isn't created twice
- DALI_ASSERT_ALWAYS( (mEglContext == 0) && "EGL context recreated" );
-
- mEglContext = eglCreateContext(mEglDisplay, mEglConfig, NULL, &(mContextAttribs[0]));
- TEST_EGL_ERROR("eglCreateContext render thread");
-
- DALI_ASSERT_ALWAYS( EGL_NO_CONTEXT != mEglContext && "EGL context not created" );
-
- return true;
-}
-
-void EglImplementation::DestroyContext()
-{
- DALI_ASSERT_ALWAYS( mEglContext && "no EGL context" );
-
- eglDestroyContext( mEglDisplay, mEglContext );
- mEglContext = 0;
-}
-
-void EglImplementation::DestroySurface()
-{
- if(mIsOwnSurface && mEglSurface)
- {
- eglDestroySurface( mEglDisplay, mEglSurface );
- mEglSurface = 0;
- }
-}
-
-void EglImplementation::MakeContextCurrent()
-{
- mContextCurrent = true;
-
- if(mIsOwnSurface)
- {
- eglMakeCurrent( mEglDisplay, mEglSurface, mEglSurface, mEglContext );
- }
-
- EGLint error = eglGetError();
-
- if ( error != EGL_SUCCESS )
- {
- switch (error)
- {
- case EGL_BAD_DISPLAY:
- {
- DALI_LOG_ERROR("EGL_BAD_DISPLAY : Display is not an EGL display connection");
- break;
- }
- case EGL_NOT_INITIALIZED:
- {
- DALI_LOG_ERROR("EGL_NOT_INITIALIZED : Display has not been initialized");
- break;
- }
- case EGL_BAD_SURFACE:
- {
- DALI_LOG_ERROR("EGL_BAD_SURFACE : Draw or read is not an EGL surface");
- break;
- }
- case EGL_BAD_CONTEXT:
- {
- DALI_LOG_ERROR("EGL_BAD_CONTEXT : Context is not an EGL rendering context");
- break;
- }
- case EGL_BAD_MATCH:
- {
- DALI_LOG_ERROR("EGL_BAD_MATCH : Draw or read are not compatible with context, or if context is set to EGL_NO_CONTEXT and draw or read are not set to EGL_NO_SURFACE, or if draw or read are set to EGL_NO_SURFACE and context is not set to EGL_NO_CONTEXT");
- break;
- }
- case EGL_BAD_ACCESS:
- {
- DALI_LOG_ERROR("EGL_BAD_ACCESS : Context is current to some other thread");
- break;
- }
- case EGL_BAD_NATIVE_PIXMAP:
- {
- DALI_LOG_ERROR("EGL_BAD_NATIVE_PIXMAP : A native pixmap underlying either draw or read is no longer valid.");
- break;
- }
- case EGL_BAD_NATIVE_WINDOW:
- {
- DALI_LOG_ERROR("EGL_BAD_NATIVE_WINDOW : A native window underlying either draw or read is no longer valid.");
- break;
- }
- case EGL_BAD_CURRENT_SURFACE:
- {
- DALI_LOG_ERROR("EGL_BAD_CURRENT_SURFACE : The previous context has unflushed commands and the previous surface is no longer valid.");
- break;
- }
- case EGL_BAD_ALLOC:
- {
- DALI_LOG_ERROR("EGL_BAD_ALLOC : Allocation of ancillary buffers for draw or read were delayed until eglMakeCurrent is called, and there are not enough resources to allocate them");
- break;
- }
- case EGL_CONTEXT_LOST:
- {
- DALI_LOG_ERROR("EGL_CONTEXT_LOST : If a power management event has occurred. The application must destroy all contexts and reinitialise OpenGL ES state and objects to continue rendering");
- break;
- }
- default:
- {
- DALI_LOG_ERROR("Unknown error");
- break;
- }
- }
- DALI_ASSERT_ALWAYS(false && "MakeContextCurrent failed!");
- }
-
- // We want to display this information all the time, so use the LogMessage directly
- Integration::Log::LogMessage(Integration::Log::DebugInfo, "EGL Information\n"
- " Vendor: %s\n"
- " Version: %s\n"
- " Client APIs: %s\n"
- " Extensions: %s\n",
- eglQueryString(mEglDisplay, EGL_VENDOR),
- eglQueryString(mEglDisplay, EGL_VERSION),
- eglQueryString(mEglDisplay, EGL_CLIENT_APIS),
- eglQueryString(mEglDisplay, EGL_EXTENSIONS));
-
- if ( mIsWindow )
- {
- SetRefreshSync( mSyncMode );
- }
-}
-
-void EglImplementation::MakeContextNull()
-{
- mContextCurrent = false;
- // clear the current context
- eglMakeCurrent( mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
-}
-
-void EglImplementation::TerminateGles()
-{
- if ( mGlesInitialized )
- {
- // in latest Mali DDK (r2p3 ~ r3p0 in April, 2012),
- // MakeContextNull should be called before eglDestroy surface
- // to prevent crash in _mali_surface_destroy_callback
- MakeContextNull();
-
- if(mIsOwnSurface && mEglSurface)
- {
- eglDestroySurface(mEglDisplay, mEglSurface);
- }
- eglDestroyContext(mEglDisplay, mEglContext);
-
- eglTerminate(mEglDisplay);
-
- mEglDisplay = NULL;
- mEglConfig = NULL;
- mEglContext = NULL;
- mEglSurface = NULL;
-
- mGlesInitialized = false;
- }
-}
-
-bool EglImplementation::IsGlesInitialized() const
-{
- return mGlesInitialized;
-}
-
-bool EglImplementation::SetRefreshSync( SyncMode mode )
-{
- if ( mIsWindow == false )
- {
- return false;
- }
- mSyncMode = mode;
-
- // eglSwapInterval specifies the minimum number of video frame periods
- // per buffer swap for the window associated with the current context.
-
- if ( !mContextCurrent )
- {
- return true;
- }
-
- EGLBoolean ok = eglSwapInterval( mEglDisplay, mode );
- if ( !ok )
- {
- TEST_EGL_ERROR("eglSwapInterval");
- return false;
- }
-
- return true;
-}
-
-void EglImplementation::SwapBuffers()
-{
- eglSwapBuffers( mEglDisplay, mEglSurface );
-}
-
-void EglImplementation::CopyBuffers()
-{
- eglCopyBuffers( mEglDisplay, mEglSurface, mEglNativePixmap );
-}
-
-void EglImplementation::WaitGL()
-{
- eglWaitGL();
-}
-
-void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
-{
- if(mEglConfig && isWindowType == mIsWindow && mColorDepth == depth)
- {
- return;
- }
-
- mIsWindow = isWindowType;
-
- EGLint numConfigs;
- Vector<EGLint> configAttribs;
- configAttribs.Reserve(31);
-
- if(isWindowType)
- {
- configAttribs.PushBack( EGL_SURFACE_TYPE );
- configAttribs.PushBack( EGL_WINDOW_BIT );
- }
- else
- {
- configAttribs.PushBack( EGL_SURFACE_TYPE );
- configAttribs.PushBack( EGL_PIXMAP_BIT );
- }
-
- configAttribs.PushBack( EGL_RENDERABLE_TYPE );
-
-#if DALI_GLES_VERSION >= 30
-
-#ifdef _ARCH_ARM_
- configAttribs.PushBack( EGL_OPENGL_ES3_BIT_KHR );
-#else
- // There is a bug in the desktop emulator
- // Requesting for ES3 causes eglCreateContext even though it allows to ask
- // for a configuration that supports GLES 3.0
- configAttribs.PushBack( EGL_OPENGL_ES2_BIT );
-#endif // _ARCH_ARM_
-
-#else // DALI_GLES_VERSION >= 30
-
- configAttribs.PushBack( EGL_OPENGL_ES2_BIT );
-
-#endif //DALI_GLES_VERSION >= 30
-
-#if DALI_GLES_VERSION >= 30
-// TODO: enable this flag when it becomes supported
-// configAttribs.PushBack( EGL_CONTEXT_FLAGS_KHR );
-// configAttribs.PushBack( EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR );
-#endif //DALI_GLES_VERSION >= 30
-
- configAttribs.PushBack( EGL_RED_SIZE );
- configAttribs.PushBack( 8 );
- configAttribs.PushBack( EGL_GREEN_SIZE );
- configAttribs.PushBack( 8 );
- configAttribs.PushBack( EGL_BLUE_SIZE );
- configAttribs.PushBack( 8 );
-
- configAttribs.PushBack( EGL_ALPHA_SIZE );
-#ifdef _ARCH_ARM_
- configAttribs.PushBack( (depth == COLOR_DEPTH_32) ? 8 : 0 );
-#else
- // There is a bug in the desktop emulator
- // setting EGL_ALPHA_SIZE to 8 results in eglChooseConfig failing
- configAttribs.PushBack( 0 );
-#endif // _ARCH_ARM_
-
- configAttribs.PushBack( EGL_DEPTH_SIZE );
- configAttribs.PushBack( 24 );
- configAttribs.PushBack( EGL_STENCIL_SIZE );
- configAttribs.PushBack( 8 );
- configAttribs.PushBack( EGL_SAMPLES );
- configAttribs.PushBack( 4 );
- configAttribs.PushBack( EGL_SAMPLE_BUFFERS );
- configAttribs.PushBack( 1 );
- configAttribs.PushBack( EGL_NONE );
-
- if ( eglChooseConfig( mEglDisplay, &(configAttribs[0]), &mEglConfig, 1, &numConfigs ) != EGL_TRUE )
- {
- EGLint error = eglGetError();
- switch (error)
- {
- case EGL_BAD_DISPLAY:
- {
- DALI_LOG_ERROR("Display is not an EGL display connection");
- break;
- }
- case EGL_BAD_ATTRIBUTE:
- {
- DALI_LOG_ERROR("The parameter confirAttribs contains an invalid frame buffer configuration attribute or an attribute value that is unrecognized or out of range");
- break;
- }
- case EGL_NOT_INITIALIZED:
- {
- DALI_LOG_ERROR("Display has not been initialized");
- break;
- }
- case EGL_BAD_PARAMETER:
- {
- DALI_LOG_ERROR("The parameter numConfig is NULL");
- break;
- }
- default:
- {
- DALI_LOG_ERROR("Unknown error");
- }
- }
- DALI_ASSERT_ALWAYS(false && "eglChooseConfig failed!");
- }
-
- if ( numConfigs != 1 )
- {
- DALI_LOG_ERROR("No configurations found.");
-
- TEST_EGL_ERROR("eglChooseConfig");
- }
-}
-
-
-void EglImplementation::CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth )
-{
- DALI_ASSERT_ALWAYS( ( mEglSurface == 0 ) && "EGL surface already exists" );
-
- mEglNativeWindow = window;
- mColorDepth = depth;
- mIsWindow = true;
-
- // egl choose config
- ChooseConfig(mIsWindow, mColorDepth);
-
- mEglSurface = eglCreateWindowSurface( mEglDisplay, mEglConfig, mEglNativeWindow, NULL );
- TEST_EGL_ERROR("eglCreateWindowSurface");
-
- DALI_ASSERT_ALWAYS( mEglSurface && "Create window surface failed" );
-}
-
-void EglImplementation::CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth )
-{
- DALI_ASSERT_ALWAYS( mEglSurface == 0 && "Cannot create more than one instance of surface pixmap" );
-
- mEglNativePixmap = pixmap;
- mColorDepth = depth;
- mIsWindow = false;
-
- // egl choose config
- ChooseConfig(mIsWindow, mColorDepth);
-
- mEglSurface = eglCreatePixmapSurface( mEglDisplay, mEglConfig, mEglNativePixmap, NULL );
- TEST_EGL_ERROR("eglCreatePixmapSurface");
-
- DALI_ASSERT_ALWAYS( mEglSurface && "Create pixmap surface failed" );
-}
-
-bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window, EGLNativeDisplayType display )
-{
- bool contextLost = false;
-
- // the surface is bound to the context, so set the context to null
- MakeContextNull();
-
- // destroy the surface
- DestroySurface();
-
- // If the display has not changed, then we can just create a new surface
- if ( display == mEglNativeDisplay )
- {
- // create the EGL surface
- CreateSurfaceWindow( window, mColorDepth );
-
- // set the context to be current with the new surface
- MakeContextCurrent();
- }
- else // the display has changed, we need to start egl with a new x-connection
- {
- // Note! this code path is untested
-
- // this will release all EGL specific resources
- eglTerminate( mEglDisplay );
-
- mGlesInitialized = false;
-
- // let the adaptor know that all resources have been lost
- contextLost = true;
-
- // re-initialise GLES with the new connection
- InitializeGles( display );
-
- // create the EGL surface
- CreateSurfaceWindow( window, mColorDepth );
-
- // create the OpenGL context
- CreateContext();
-
- // Make it current
- MakeContextCurrent();
- }
-
- return contextLost;
-}
-
-bool EglImplementation::ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLNativeDisplayType display )
-{
- bool contextLost = false;
-
- // the surface is bound to the context, so set the context to null
- MakeContextNull();
-
- // destroy the surface
- DestroySurface();
-
- // If the display has not changed, then we can just create a new surface
- if ( display == mEglNativeDisplay )
- {
- // create the EGL surface
- CreateSurfacePixmap( pixmap, mColorDepth );
-
- // set the context to be current with the new surface
- MakeContextCurrent();
- }
- else // the display has changed, we need to start egl with a new x-connection
- {
- // Note! this code path is untested
-
- // this will release all EGL specific resources
- eglTerminate( mEglDisplay );
-
- mGlesInitialized = false;
-
- // let the adaptor know that all resources have been lost
- contextLost = true;
-
- // re-initialise GLES with the new connection
- InitializeGles( display );
-
- // create the EGL surface
- CreateSurfacePixmap( pixmap, mColorDepth );
-
- // create the OpenGL context
- CreateContext();
-
- // Make it current
- MakeContextCurrent();
- }
- return contextLost;
-}
-
-EGLDisplay EglImplementation::GetDisplay() const
-{
- return mEglDisplay;
-}
-
-EGLDisplay EglImplementation::GetContext() const
-{
- return mEglContext;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
+++ /dev/null
-#ifndef __DALI_INTERNAL_EGL_IMPLEMENTATION_H__
-#define __DALI_INTERNAL_EGL_IMPLEMENTATION_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <boost/any.hpp>
-#include <dali/public-api/common/dali-vector.h>
-
-// INTERNAL INCLUDES
-#include <base/interfaces/egl-interface.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-enum ColorDepth
-{
- COLOR_DEPTH_24 = 24,
- COLOR_DEPTH_32 = 32
-};
-
-/**
- * EglImplementation class provides an EGL implementation.
- */
-class EglImplementation : public EglInterface
-{
-public:
- /**
- * Constructor
- */
- EglImplementation();
-
- /**
- * Destructor
- */
- virtual ~EglImplementation();
-
-public:
-
- /**
- * (Called from ECoreX::RenderSurface, not RenderThread, so not in i/f, hence, not virtual)
- * Initialize GL
- * @param display The display
- * @param isOwnSurface whether the surface is own or not
- * @return true on success, false on failure
- */
- bool InitializeGles( EGLNativeDisplayType display, bool isOwnSurface = true );
-
- /**
- * Create the OpenGL context.
- * @return true if successful
- */
- virtual bool CreateContext();
-
- /**
- * Destroy the OpenGL context.
- */
- void DestroyContext();
-
- /**
- * Destroy the OpenGL surface.
- */
- void DestroySurface();
-
- /**
- * Make the OpenGL context current
- */
- virtual void MakeContextCurrent();
-
- /**
- * clear the OpenGL context
- */
- void MakeContextNull();
-
- /**
- * Terminate GL
- */
- virtual void TerminateGles();
-
- /**
- * Checks if GL is initialised
- * @return true if it is
- */
- bool IsGlesInitialized() const;
-
- /**
- * Sets the refresh sync mode.
- * @see SyncMode
- */
- virtual bool SetRefreshSync( SyncMode mode );
-
- /**
- * Performs an OpenGL swap buffers command
- */
- virtual void SwapBuffers();
-
- /**
- * Performs an OpenGL copy buffers command
- */
- virtual void CopyBuffers();
-
- /**
- * Performs an EGL wait GL command
- */
- virtual void WaitGL();
-
- /**
- * Choose config of egl
- * @param isWindowType whether the config for window or pixmap
- * @param colorDepth Bit per pixel value (ex. 32 or 24)
- */
- void ChooseConfig( bool isWindowType, ColorDepth depth );
-
- /**
- * Create an OpenGL surface using a window
- * @param window The window to create the surface on
- * @param colorDepth Bit per pixel value (ex. 32 or 24)
- * @return true on success, false on failure
- */
- void CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth );
-
- /**
- * Create the OpenGL surface using a pixmap
- * @param pixmap The pixmap to create the surface on
- * @param colorDepth Bit per pixel value (ex. 32 or 24)
- * @return true on success, false on failure
- */
- void CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth );
-
- /**
- * Replaces the render surface
- * @param[in] window, the window to create the new surface on
- * @param[in] display, the display
- * @return true if the context was lost due to a change in display
- * between old surface and new surface
- */
- bool ReplaceSurfaceWindow( EGLNativeWindowType window, EGLNativeDisplayType display );
-
- /**
- * Replaces the render surface
- * @param[in] pixmap, the pixmap to create the new surface on
- * @param[in] display, the display
- * @return true if the context was lost due to a change in x-display
- * between old surface and new surface
- */
- bool ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLNativeDisplayType display );
-
- /**
- * returns the display with which this object was initialized
- * @return the EGL Display.
- */
- EGLDisplay GetDisplay() const;
-
- /**
- * Returns the EGL context
- * @return the EGL context.
- */
- EGLContext GetContext() const;
-
-private:
-
- Vector<EGLint> mContextAttribs;
-
- EGLNativeDisplayType mEglNativeDisplay;
- EGLNativeWindowType mEglNativeWindow;
- EGLNativePixmapType mEglNativePixmap;
-
- EGLDisplay mEglDisplay;
- EGLConfig mEglConfig;
- EGLContext mEglContext;
- EGLSurface mEglSurface;
-
- bool mGlesInitialized;
- bool mIsOwnSurface;
- SyncMode mSyncMode;
- bool mContextCurrent;
- bool mIsWindow;
- ColorDepth mColorDepth;
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_EGL_IMPLEMENTATION_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <internal/common/gl/egl-sync-implementation.h>
-
-// EXTERNAL INCLUDES
-
-#ifdef _ARCH_ARM_
-
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#include <EGL/eglext.h>
-
-#endif
-
-#include <boost/thread/mutex.hpp>
-
-// INTERNAL INCLUDES
-#include <internal/common/gl/egl-implementation.h>
-#include <dali/integration-api/debug.h>
-
-#ifdef _ARCH_ARM_
-
-// function pointers
-static PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR = NULL;
-static PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR = NULL;
-static PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR = NULL;
-
-#endif
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-#ifdef _ARCH_ARM_
-
-EglSyncObject::EglSyncObject( EglImplementation& eglSyncImpl )
-: mEglSync(NULL),
- mEglImplementation(eglSyncImpl)
-{
- EGLDisplay display = mEglImplementation.GetDisplay();
- mEglSync = eglCreateSyncKHR( display, EGL_SYNC_FENCE_KHR, NULL );
- if (mEglSync == EGL_NO_SYNC_KHR)
- {
- DALI_LOG_ERROR("eglCreateSyncKHR failed %#0.4x\n", eglGetError());
- mEglSync = NULL;
- }
-}
-
-EglSyncObject::~EglSyncObject()
-{
- if( mEglSync != NULL )
- {
- eglDestroySyncKHR( mEglImplementation.GetDisplay(), mEglSync );
- EGLint error = eglGetError();
- if( EGL_SUCCESS != error )
- {
- DALI_LOG_ERROR("eglDestroySyncKHR failed %#0.4x\n", error);
- }
- }
-}
-
-bool EglSyncObject::IsSynced()
-{
- bool synced = false;
-
- if( mEglSync != NULL )
- {
- EGLint result = eglClientWaitSyncKHR( mEglImplementation.GetDisplay(), mEglSync, 0, 0ull );
- EGLint error = eglGetError();
- if( EGL_SUCCESS != error )
- {
- DALI_LOG_ERROR("eglClientWaitSyncKHR failed %#0.4x\n", error);
- }
- else if( result == EGL_CONDITION_SATISFIED_KHR )
- {
- synced = true;
- }
- }
-
- return synced;
-}
-
-EglSyncImplementation::EglSyncImplementation()
-: mEglImplementation( NULL ),
- mSyncInitialized( false ),
- mSyncInitializeFailed( false )
-{
-}
-
-EglSyncImplementation::~EglSyncImplementation()
-{
-}
-
-void EglSyncImplementation::Initialize( EglImplementation* eglImpl )
-{
- mEglImplementation = eglImpl;
-}
-
-Integration::GlSyncAbstraction::SyncObject* EglSyncImplementation::CreateSyncObject()
-{
- DALI_ASSERT_ALWAYS( mEglImplementation && "Sync Implementation not initialized" );
- if( mSyncInitialized == false )
- {
- InitializeEglSync();
- }
-
- EglSyncObject* syncObject = new EglSyncObject(*mEglImplementation);
- mSyncObjects.PushBack( syncObject );
- return syncObject;
-}
-
-void EglSyncImplementation::DestroySyncObject( Integration::GlSyncAbstraction::SyncObject* syncObject )
-{
- DALI_ASSERT_ALWAYS( mEglImplementation && "Sync Implementation not initialized" );
-
- if( mSyncInitialized == false )
- {
- InitializeEglSync();
- }
-
- for( SyncIter iter=mSyncObjects.Begin(), end=mSyncObjects.End(); iter != end; ++iter )
- {
- if( *iter == syncObject )
- {
- mSyncObjects.Erase(iter);
- break;
- }
- }
- EglSyncObject* eglSyncObject = static_cast<EglSyncObject*>(syncObject);
- delete eglSyncObject;
-}
-
-void EglSyncImplementation::InitializeEglSync()
-{
- if( ! mSyncInitializeFailed )
- {
- eglCreateSyncKHR = (PFNEGLCREATESYNCKHRPROC)eglGetProcAddress("eglCreateSyncKHR");
- eglClientWaitSyncKHR = (PFNEGLCLIENTWAITSYNCKHRPROC)eglGetProcAddress("eglClientWaitSyncKHR");
- eglDestroySyncKHR = (PFNEGLDESTROYSYNCKHRPROC)eglGetProcAddress("eglDestroySyncKHR");
- }
-
- if( eglCreateSyncKHR && eglClientWaitSyncKHR && eglDestroySyncKHR )
- {
- mSyncInitialized = true;
- }
- else
- {
- mSyncInitializeFailed = true;
- }
-}
-
-#else
-
-EglSyncObject::EglSyncObject( EglImplementation& eglImpl )
-: mPollCounter(3),
- mEglImplementation(eglImpl)
-{
-}
-
-EglSyncObject::~EglSyncObject()
-{
-}
-
-bool EglSyncObject::IsSynced()
-{
- if(mPollCounter <= 0)
- {
- return true;
- }
- --mPollCounter;
- return false;
-}
-
-EglSyncImplementation::EglSyncImplementation()
-: mEglImplementation( NULL )
-{
-}
-
-EglSyncImplementation::~EglSyncImplementation()
-{
-}
-
-void EglSyncImplementation::Initialize( EglImplementation* eglImpl )
-{
- mEglImplementation = eglImpl;
-}
-
-Integration::GlSyncAbstraction::SyncObject* EglSyncImplementation::CreateSyncObject()
-{
- DALI_ASSERT_ALWAYS( mEglImplementation && "Sync Implementation not initialized" );
- return new EglSyncObject(*mEglImplementation);
-}
-
-void EglSyncImplementation::DestroySyncObject(Integration::GlSyncAbstraction::SyncObject* syncObject)
-{
- DALI_ASSERT_ALWAYS( mEglImplementation && "Sync Implementation not initialized" );
-
- // The abstraction's virtual destructor is protected, so that Core can't delete the sync objects
- // directly (This object also needs removing from the mSyncObject container in the ARM
- // implementation above). We therefore need to cast to the actual implementation object first.
- EglSyncObject* eglSyncObject = static_cast<EglSyncObject*>(syncObject);
- delete eglSyncObject;
-}
-
-void EglSyncImplementation::InitializeEglSync()
-{
-}
-
-#endif
-
-} // namespace Dali
-} // namespace Internal
-} // namespace Adaptor
+++ /dev/null
-#ifndef __DALI_INTERNAL_ADAPTOR_EGL_SYNC_IMPLEMENTATION_H__
-#define __DALI_INTERNAL_ADAPTOR_EGL_SYNC_IMPLEMENTATION_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/common/dali-vector.h>
-#include <dali/integration-api/gl-sync-abstraction.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-class EglImplementation;
-
-class EglSyncObject : public Integration::GlSyncAbstraction::SyncObject
-{
-public:
- /**
- * Constructor
- */
- EglSyncObject( EglImplementation& eglSyncImpl );
-
- /**
- * Destructor
- */
- virtual ~EglSyncObject();
-
- /**
- * @copydoc Dali::Integration::GlSyncAbstraction::SyncObject::IsSynced()
- */
- virtual bool IsSynced();
-
-private:
-#ifdef _ARCH_ARM_
- EGLSyncKHR mEglSync;
-#else
- int mPollCounter; // Implementations without fence sync use a 3 frame counter
-#endif
- EglImplementation& mEglImplementation;
-};
-
-
-/**
- * GlSyncImplementation is a concrete implementation for GlSyncAbstraction.
- * It provides fence syncing for resources such as FrameBuffers using EGL extensions
- *
- * Sync objects are created in the render thread after a render instruction
- * has been processed (i.e. GL draw calls have completed for a given FB), and
- * tested in the update
- */
-class EglSyncImplementation : public Integration::GlSyncAbstraction
-{
-public:
- /**
- * Constructor
- */
- EglSyncImplementation();
-
- /**
- * Destructor
- */
- virtual ~EglSyncImplementation();
-
- /**
- * Initialize the sync object with the Egl implementation.
- * @param[in] impl The EGL implementation (to access display)
- */
- void Initialize( EglImplementation* impl );
-
- /**
- * @copydoc Dali::Integration::GlSyncAbstraction::CreateSyncObject()
- */
- virtual SyncObject* CreateSyncObject();
-
- /**
- * @copydoc Dali::Integration::GlSyncAbstraction::DestroySyncObject()
- */
- virtual void DestroySyncObject(SyncObject* syncObject);
-
-private:
- /**
- * Set up the function pointers
- */
- void InitializeEglSync();
-
-private:
- typedef Vector<EglSyncObject*> SyncContainer;
- typedef SyncContainer::Iterator SyncIter;
-
- EglImplementation* mEglImplementation; ///< Egl implementation (to get display)
- bool mSyncInitialized; ///< Flag to perform initialization on first use
- bool mSyncInitializeFailed; ///< Flag to avoid reloading functions if failed once
-
- SyncContainer mSyncObjects;
-};
-
-} // namespace Adaptor
-} // namespace Internal
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_EGL_ADAPTOR_SYNC_IMPLEMENTATION_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "gl-extensions.h"
-
-// EXTERNAL INCLUDES
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-// INTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace ECoreX
-{
-
-GlExtensions::GlExtensions()
- : mInitialized( false )
-{
-}
-
-GlExtensions::~GlExtensions()
-{
-}
-
-#if DALI_GLES_VERSION < 30
-
-void GlExtensions::DiscardFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
-{
- // initialize extension on first use as on some hw platforms a context
- // has to be bound for the extensions to return correct pointer
- if( !mInitialized )
- {
- Initialize();
- }
-
-#ifdef PFNGLDISCARDFRAMEBUFFEREXTPROC
- if( mGlDiscardFramebuffer )
- {
- mGlDiscardFramebuffer(target, numAttachments, attachments);
- }
- else
- {
- DALI_LOG_ERROR("Error: glDiscardFramebufferEXT extension is not available\n");
- }
-#endif
-}
-
-void GlExtensions::GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
-{
- // initialize extension on first use as on some hw platforms a context
- // has to be bound for the extensions to return correct pointer
- if( !mInitialized )
- {
- Initialize();
- }
-
-#ifdef PFNGLGETPROGRAMBINARYOESPROC
- if (mGlGetProgramBinaryOES)
- {
- mGlGetProgramBinaryOES(program, bufSize, length, binaryFormat, binary);
- }
- else
- {
- DALI_LOG_ERROR("Error: glGetProgramBinaryOES extension is not available\n");
- DALI_ASSERT_DEBUG(0);
- }
-#endif
-}
-
-void GlExtensions::ProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length)
-{
- // initialize extension on first use as on some hw platforms a context
- // has to be bound for the extensions to return correct pointer
- if( !mInitialized )
- {
- Initialize();
- }
-
-#ifdef PFNGLGETPROGRAMBINARYOESPROC
- if (mGlProgramBinaryOES)
- {
- mGlProgramBinaryOES(program, binaryFormat, binary, length);
- }
- else
- {
- DALI_LOG_ERROR("Error: glProgramBinaryOES extension is not available\n");
- DALI_ASSERT_DEBUG(0);
- }
-#endif
-}
-
-void GlExtensions::Initialize()
-{
- mInitialized = true;
-
-#ifdef PFNGLDISCARDFRAMEBUFFEREXTPROC
- mGlDiscardFramebuffer = (PFNGLDISCARDFRAMEBUFFEREXTPROC) eglGetProcAddress("glDiscardFramebufferEXT");
-#endif
-
-#ifdef PFNGLGETPROGRAMBINARYOESPROC
- mGlGetProgramBinaryOES = (PFNGLGETPROGRAMBINARYOESPROC) eglGetProcAddress("glGetProgramBinaryOES");
- mGlProgramBinaryOES = (PFNGLPROGRAMBINARYOESPROC) eglGetProcAddress("glProgramBinaryOES");
-#endif
-
-}
-
-#endif // DALI_GLES_VERSION < 30
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_GL_EXTENSION_H__
-#define __DALI_INTERNAL_GL_EXTENSION_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-
-#if DALI_GLES_VERSION >= 30
-#include <GLES3/gl3.h>
-#include <GLES3/gl3ext.h>
-#else
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#endif
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace ECoreX
-{
-
-/**
- * GlExtensions class provides GL extensions support
- */
-class GlExtensions
-{
-public:
-
- /**
- * Constructor
- */
- GlExtensions();
-
- /**
- * Destructor
- */
- ~GlExtensions();
-
-
-public:
-
-#if DALI_GLES_VERSION < 30
-
- /**
- * If the GL extension is available this function discards specified data in attachments
- * from being copied from the target to improve performance.
- *
- * Usage: GLenum attachments[] = { GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT };
- * DiscardFrameBufferEXT(GL_FRAMEBUFFER, 2, attachments);
- *
- * @param target is usually GL_FRAMEBUFFER
- * @param numAttachments is the count of attachments
- * @param attachments is a pointer to the attachments
- */
- void DiscardFrameBuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments);
-
- /**
- * GLES extension
- * Returns the program object's executable bytecode.
- * @param[in] program The program object's name/id
- * @param[in] bufSize The maximum number of bytes that may be written into binary
- * @param[out] length The actual number of bytes written into binary
- * @param[out] binaryFormat The format of the program binary
- * @param[out] binary The actual program bytecode
- */
- void GetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
-
- /**
- * GLES extension
- * Loads a program object with a program binary previously returned from GetProgramBinaryOES
- * @param[in] program The program object's name/id
- * @param[in] binaryFormat The format of the program binary
- * @param[in] binary The program bytecode
- * @param[in] length The number of bytes in binary
- */
- void ProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
-
-#endif // DALI_GLES_VERSION < 30
-
-private:
-
- /**
- * Lazy Initialize extensions on first use
- */
- void Initialize();
-
-#if DALI_GLES_VERSION < 30
-
-#ifdef PFNGLDISCARDFRAMEBUFFEREXTPROC
- PFNGLDISCARDFRAMEBUFFEREXTPROC mGlDiscardFramebuffer;
-#endif
-
-
-#ifdef PFNGLGETPROGRAMBINARYOESPROC
- PFNGLGETPROGRAMBINARYOESPROC mGlGetProgramBinaryOES;
- PFNGLPROGRAMBINARYOESPROC mGlProgramBinaryOES;
-#endif
-
-#endif // DALI_GLES_VERSION < 30
-
- bool mInitialized;
-
-};
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif /* __DALI_INTERNAL_GL_EXTENSION_H__ */
+++ /dev/null
-#ifndef __DALI_INTERNAL_GL_IMPLEMENTATION_H__
-#define __DALI_INTERNAL_GL_IMPLEMENTATION_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#ifndef DALI_GLES_VERSION
-#error "OpenGL ES version not specified"
-#endif
-
-#if DALI_GLES_VERSION >= 30
-#include <GLES3/gl3.h>
-#else
-#include <cstdlib>
-#include <GLES2/gl2.h>
-#endif
-
-#include <dali/integration-api/gl-abstraction.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/gl/gl-extensions.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * GlImplementation is a concrete implementation for GlAbstraction.
- * The class provides an OpenGL-ES 2.0 implementation.
- * The class is provided when creating the Integration::Core object.
- */
-class GlImplementation: public Dali::Integration::GlAbstraction
-{
-
-public:
- virtual ~GlImplementation() {}
-
- void PreRender()
- {
- /* Do nothing in main implementation */
- }
-
- void PostRender( unsigned int timeDelta )
- {
- /* Do nothing in main implementation */
- }
-
- /* OpenGL ES 2.0 */
-
- void ActiveTexture (GLenum texture)
- {
- glActiveTexture(texture);
- }
-
- void AttachShader (GLuint program, GLuint shader)
- {
- glAttachShader(program,shader);
- }
-
- void BindAttribLocation (GLuint program, GLuint index, const char* name)
- {
- glBindAttribLocation(program,index,name);
- }
-
- void BindBuffer (GLenum target, GLuint buffer)
- {
- glBindBuffer(target,buffer);
- }
-
- void BindFramebuffer (GLenum target, GLuint framebuffer)
- {
- glBindFramebuffer(target,framebuffer);
- }
-
- void BindRenderbuffer (GLenum target, GLuint renderbuffer)
- {
- glBindRenderbuffer(target,renderbuffer);
- }
-
- void BindTexture (GLenum target, GLuint texture)
- {
- glBindTexture(target,texture);
- }
-
- void BlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
- {
- glBlendColor(red,green,blue,alpha);
- }
-
- void BlendEquation ( GLenum mode )
- {
- glBlendEquation(mode);
- }
-
- void BlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha)
- {
- glBlendEquationSeparate(modeRGB,modeAlpha);
- }
-
- void BlendFunc (GLenum sfactor, GLenum dfactor)
- {
- glBlendFunc(sfactor,dfactor);
- }
-
- void BlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
- {
- glBlendFuncSeparate(srcRGB,dstRGB,srcAlpha,dstAlpha);
- }
-
- void BufferData (GLenum target, GLsizeiptr size, const void* data, GLenum usage)
- {
- glBufferData(target,size,data,usage);
- }
-
- void BufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
- {
- glBufferSubData(target,offset,size,data);
- }
-
- GLenum CheckFramebufferStatus (GLenum target)
- {
- return glCheckFramebufferStatus(target);
- }
-
- void Clear (GLbitfield mask)
- {
- glClear(mask);
- }
-
- void ClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
- {
- glClearColor(red,green,blue,alpha);
- }
-
- void ClearDepthf (GLclampf depth)
- {
- glClearDepthf(depth);
- }
-
- void ClearStencil (GLint s)
- {
- glClearStencil(s);
- }
-
- void ColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
- {
- glColorMask(red,green,blue,alpha);
- }
-
- void CompileShader (GLuint shader)
- {
- glCompileShader(shader);
- }
-
- void CompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
- {
- glCompressedTexImage2D(target,level,internalformat,width,height,border,imageSize,data);
- }
-
- void CompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
- {
- glCompressedTexSubImage2D(target,level,xoffset,yoffset,width,height,format,imageSize,data);
- }
-
- void CopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
- {
- glCopyTexImage2D(target,level,internalformat,x,y,width,height,border);
- }
-
- void CopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
- {
- glCopyTexSubImage2D(target,level,xoffset,yoffset,x,y,width,height);
- }
-
- GLuint CreateProgram (void)
- {
- return glCreateProgram();
- }
-
- GLuint CreateShader (GLenum type)
- {
- return glCreateShader(type);
- }
-
- void CullFace (GLenum mode)
- {
- glCullFace(mode);
- }
-
- void DeleteBuffers (GLsizei n, const GLuint* buffers)
- {
- glDeleteBuffers(n,buffers);
- }
-
- void DeleteFramebuffers (GLsizei n, const GLuint* framebuffers)
- {
- glDeleteFramebuffers(n,framebuffers);
- }
-
- void DeleteProgram (GLuint program)
- {
- glDeleteProgram(program);
- }
-
- void DeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers)
- {
- glDeleteRenderbuffers(n,renderbuffers);
- }
-
- void DeleteShader (GLuint shader)
- {
- glDeleteShader(shader);
- }
-
- void DeleteTextures (GLsizei n, const GLuint* textures)
- {
- glDeleteTextures(n,textures);
- }
-
- void DepthFunc (GLenum func)
- {
- glDepthFunc(func);
- }
-
- void DepthMask (GLboolean flag)
- {
- glDepthMask(flag);
- }
-
- void DepthRangef (GLclampf zNear, GLclampf zFar)
- {
- glDepthRangef(zNear,zFar);
- }
-
- void DetachShader (GLuint program, GLuint shader)
- {
- glDetachShader(program,shader);
- }
-
- void Disable (GLenum cap)
- {
- glDisable(cap);
- }
-
- void DisableVertexAttribArray (GLuint index)
- {
- glDisableVertexAttribArray(index);
- }
-
- void DrawArrays (GLenum mode, GLint first, GLsizei count)
- {
- glDrawArrays(mode,first,count);
- }
-
- void DrawElements (GLenum mode, GLsizei count, GLenum type, const void* indices)
- {
- glDrawElements(mode,count,type,indices);
- }
-
- void Enable (GLenum cap)
- {
- glEnable(cap);
- }
-
- void EnableVertexAttribArray (GLuint index)
- {
- glEnableVertexAttribArray(index);
- }
-
- void Finish (void)
- {
- glFinish();
- }
-
- void Flush (void)
- {
- glFlush();
- }
-
- void FramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
- {
- glFramebufferRenderbuffer(target,attachment,renderbuffertarget,renderbuffer);
- }
-
- void FramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
- {
- glFramebufferTexture2D(target,attachment,textarget,texture,level);
- }
-
- void FrontFace (GLenum mode)
- {
- glFrontFace(mode);
- }
-
- void GenBuffers (GLsizei n, GLuint* buffers)
- {
- glGenBuffers(n,buffers);
- }
-
- void GenerateMipmap (GLenum target)
- {
- glGenerateMipmap(target);
- }
-
- void GenFramebuffers (GLsizei n, GLuint* framebuffers)
- {
- glGenFramebuffers(n,framebuffers);
- }
-
- void GenRenderbuffers (GLsizei n, GLuint* renderbuffers)
- {
- glGenRenderbuffers(n,renderbuffers);
- }
-
- void GenTextures (GLsizei n, GLuint* textures)
- {
- glGenTextures(n,textures);
- }
-
- void GetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
- {
- glGetActiveAttrib(program,index,bufsize,length,size,type,name);
- }
-
- void GetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
- {
- glGetActiveUniform(program,index,bufsize,length,size,type,name);
- }
-
- void GetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
- {
- glGetAttachedShaders(program,maxcount,count,shaders);
- }
-
- int GetAttribLocation (GLuint program, const char* name)
- {
- return glGetAttribLocation(program,name);
- }
-
- void GetBooleanv (GLenum pname, GLboolean* params)
- {
- glGetBooleanv(pname,params);
- }
-
- void GetBufferParameteriv (GLenum target, GLenum pname, GLint* params)
- {
- glGetBufferParameteriv(target,pname,params);
- }
-
- GLenum GetError (void)
- {
- return glGetError();
- }
-
- void GetFloatv (GLenum pname, GLfloat* params)
- {
- glGetFloatv(pname,params);
- }
-
- void GetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params)
- {
- glGetFramebufferAttachmentParameteriv(target,attachment,pname,params);
- }
-
- void GetIntegerv (GLenum pname, GLint* params)
- {
- glGetIntegerv(pname,params);
- }
-
- void GetProgramiv (GLuint program, GLenum pname, GLint* params)
- {
- glGetProgramiv(program,pname,params);
- }
-
- void GetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
- {
- glGetProgramInfoLog(program,bufsize,length,infolog);
- }
-
- void GetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params)
- {
- glGetRenderbufferParameteriv(target,pname,params);
- }
-
- void GetShaderiv (GLuint shader, GLenum pname, GLint* params)
- {
- glGetShaderiv(shader,pname,params);
- }
-
- void GetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
- {
- glGetShaderInfoLog(shader,bufsize,length,infolog);
- }
-
- void GetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
- {
- glGetShaderPrecisionFormat(shadertype,precisiontype,range,precision);
- }
-
- void GetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
- {
- glGetShaderSource(shader,bufsize,length,source);
- }
-
- const GLubyte* GetString (GLenum name)
- {
- return glGetString(name);
- }
-
- void GetTexParameterfv (GLenum target, GLenum pname, GLfloat* params)
- {
- glGetTexParameterfv(target,pname,params);
- }
-
- void GetTexParameteriv (GLenum target, GLenum pname, GLint* params)
- {
- glGetTexParameteriv(target,pname,params);
- }
-
- void GetUniformfv (GLuint program, GLint location, GLfloat* params)
- {
- glGetUniformfv(program,location,params);
- }
-
- void GetUniformiv (GLuint program, GLint location, GLint* params)
- {
- glGetUniformiv(program,location,params);
- }
-
- int GetUniformLocation (GLuint program, const char* name)
- {
- return glGetUniformLocation(program,name);
- }
-
- void GetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params)
- {
- glGetVertexAttribfv(index,pname,params);
- }
-
- void GetVertexAttribiv (GLuint index, GLenum pname, GLint* params)
- {
- glGetVertexAttribiv(index,pname,params);
- }
-
- void GetVertexAttribPointerv (GLuint index, GLenum pname, void** pointer)
- {
- glGetVertexAttribPointerv(index,pname,pointer);
- }
-
- void Hint (GLenum target, GLenum mode)
- {
- glHint(target,mode);
- }
-
- GLboolean IsBuffer (GLuint buffer)
- {
- return glIsBuffer(buffer);
- }
-
- GLboolean IsEnabled (GLenum cap)
- {
- return glIsEnabled(cap);
- }
-
- GLboolean IsFramebuffer (GLuint framebuffer)
- {
- return glIsFramebuffer(framebuffer);
- }
-
- GLboolean IsProgram (GLuint program)
- {
- return glIsProgram(program);
- }
-
- GLboolean IsRenderbuffer (GLuint renderbuffer)
- {
- return glIsRenderbuffer(renderbuffer);
- }
-
- GLboolean IsShader (GLuint shader)
- {
- return glIsShader(shader);
- }
-
- GLboolean IsTexture (GLuint texture)
- {
- return glIsTexture(texture);
- }
-
- void LineWidth (GLfloat width)
- {
- glLineWidth(width);
- }
-
- void LinkProgram (GLuint program)
- {
- glLinkProgram(program);
- }
-
- void PixelStorei (GLenum pname, GLint param)
- {
- glPixelStorei(pname,param);
- }
-
- void PolygonOffset (GLfloat factor, GLfloat units)
- {
- glPolygonOffset(factor,units);
- }
-
- void ReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
- {
- glReadPixels(x,y,width,height,format,type,pixels);
- }
-
- void ReleaseShaderCompiler (void)
- {
- glReleaseShaderCompiler();
- }
-
- void RenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
- {
- glRenderbufferStorage(target,internalformat,width,height);
- }
-
- void SampleCoverage (GLclampf value, GLboolean invert)
- {
- glSampleCoverage(value,invert);
- }
-
- void Scissor (GLint x, GLint y, GLsizei width, GLsizei height)
- {
- glScissor(x,y,width,height);
- }
-
- void ShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
- {
- glShaderBinary(n,shaders,binaryformat,binary,length);
- }
-
- void ShaderSource (GLuint shader, GLsizei count, const char** string, const GLint* length)
- {
- glShaderSource(shader,count,string,length);
- }
-
- void StencilFunc (GLenum func, GLint ref, GLuint mask)
- {
- glStencilFunc(func,ref,mask);
- }
-
- void StencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask)
- {
- glStencilFuncSeparate(face,func,ref,mask);
- }
-
- void StencilMask (GLuint mask)
- {
- glStencilMask(mask);
- }
-
- void StencilMaskSeparate (GLenum face, GLuint mask)
- {
- glStencilMaskSeparate(face,mask);
- }
-
- void StencilOp (GLenum fail, GLenum zfail, GLenum zpass)
- {
- glStencilOp(fail,zfail,zpass);
- }
-
- void StencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
- {
- glStencilOpSeparate(face,fail,zfail,zpass);
- }
-
- void TexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
- {
- glTexImage2D(target,level,internalformat,width,height,border,format,type,pixels);
- }
-
- void TexParameterf (GLenum target, GLenum pname, GLfloat param)
- {
- glTexParameterf(target,pname,param);
- }
-
- void TexParameterfv (GLenum target, GLenum pname, const GLfloat* params)
- {
- glTexParameterfv(target,pname,params);
- }
-
- void TexParameteri (GLenum target, GLenum pname, GLint param)
- {
- glTexParameteri(target,pname,param);
- }
-
- void TexParameteriv (GLenum target, GLenum pname, const GLint* params)
- {
- glTexParameteriv(target,pname,params);
- }
-
- void TexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
- {
- glTexSubImage2D(target,level,xoffset,yoffset,width,height,format,type,pixels);
- }
-
- void Uniform1f (GLint location, GLfloat x)
- {
- glUniform1f(location,x);
- }
-
- void Uniform1fv (GLint location, GLsizei count, const GLfloat* v)
- {
- glUniform1fv(location,count,v);
- }
-
- void Uniform1i (GLint location, GLint x)
- {
- glUniform1i(location,x);
- }
-
- void Uniform1iv (GLint location, GLsizei count, const GLint* v)
- {
- glUniform1iv(location,count,v);
- }
-
- void Uniform2f (GLint location, GLfloat x, GLfloat y)
- {
- glUniform2f(location,x,y);
- }
-
- void Uniform2fv (GLint location, GLsizei count, const GLfloat* v)
- {
- glUniform2fv(location,count,v);
- }
-
- void Uniform2i (GLint location, GLint x, GLint y)
- {
- glUniform2i(location,x,y);
- }
-
- void Uniform2iv (GLint location, GLsizei count, const GLint* v)
- {
- glUniform2iv(location,count,v);
- }
-
- void Uniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z)
- {
- glUniform3f(location,x,y,z);
- }
-
- void Uniform3fv (GLint location, GLsizei count, const GLfloat* v)
- {
- glUniform3fv(location,count,v);
- }
-
- void Uniform3i (GLint location, GLint x, GLint y, GLint z)
- {
- glUniform3i(location,x,y,z);
- }
-
- void Uniform3iv (GLint location, GLsizei count, const GLint* v)
- {
- glUniform3iv(location,count,v);
- }
-
- void Uniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
- {
- glUniform4f(location,x,y,z,w);
- }
-
- void Uniform4fv (GLint location, GLsizei count, const GLfloat* v)
- {
- glUniform4fv(location,count,v);
- }
-
- void Uniform4i (GLint location, GLint x, GLint y, GLint z, GLint w)
- {
- glUniform4i(location,x,y,z,w);
- }
-
- void Uniform4iv (GLint location, GLsizei count, const GLint* v)
- {
- glUniform4iv(location,count,v);
- }
-
- void UniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
- glUniformMatrix2fv(location,count,transpose,value);
- }
-
- void UniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
- glUniformMatrix3fv(location,count,transpose,value);
- }
-
- void UniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
- glUniformMatrix4fv(location,count,transpose,value);
- }
-
- void UseProgram (GLuint program)
- {
- glUseProgram(program);
- }
-
- void ValidateProgram (GLuint program)
- {
- glValidateProgram(program);
- }
-
- void VertexAttrib1f (GLuint indx, GLfloat x)
- {
- glVertexAttrib1f(indx,x);
- }
-
- void VertexAttrib1fv (GLuint indx, const GLfloat* values)
- {
- glVertexAttrib1fv(indx,values);
- }
-
- void VertexAttrib2f (GLuint indx, GLfloat x, GLfloat y)
- {
- glVertexAttrib2f(indx,x,y);
- }
-
- void VertexAttrib2fv (GLuint indx, const GLfloat* values)
- {
- glVertexAttrib2fv(indx,values);
- }
-
- void VertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z)
- {
- glVertexAttrib3f(indx,x,y,z);
- }
-
- void VertexAttrib3fv (GLuint indx, const GLfloat* values)
- {
- glVertexAttrib3fv(indx,values);
- }
-
- void VertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
- {
- glVertexAttrib4f(indx,x,y,z,w);
- }
-
- void VertexAttrib4fv (GLuint indx, const GLfloat* values)
- {
- glVertexAttrib4fv(indx,values);
- }
-
- void VertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
- {
- glVertexAttribPointer(indx,size,type,normalized,stride,ptr);
- }
-
- void Viewport (GLint x, GLint y, GLsizei width, GLsizei height)
- {
- glViewport(x,y,width,height);
- }
-
- /* OpenGL ES 3.0 */
-
- void ReadBuffer(GLenum mode)
- {
-#if DALI_GLES_VERSION >= 30
- glReadBuffer(mode);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
- {
-#if DALI_GLES_VERSION >= 30
- glDrawRangeElements(mode,start,end,count,type,indices);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
- {
-#if DALI_GLES_VERSION >= 30
- glTexImage3D(target,level,internalformat,width,height,depth,border,format,type,pixels);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
- {
-#if DALI_GLES_VERSION >= 30
- glTexSubImage3D(target,level,xoffset,yoffset,zoffset,width,height,depth,format,type,pixels);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
- {
-#if DALI_GLES_VERSION >= 30
- glCopyTexSubImage3D(target,level,xoffset,yoffset,zoffset,x,y,width,height);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
- {
-#if DALI_GLES_VERSION >= 30
- glCompressedTexImage3D(target,level,internalformat,width,height,depth,border,imageSize,data);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
- {
-#if DALI_GLES_VERSION >= 30
- glCompressedTexSubImage3D(target,level,xoffset,yoffset,zoffset,width,height,depth,format,imageSize,data);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GenQueries(GLsizei n, GLuint* ids)
- {
-#if DALI_GLES_VERSION >= 30
- glGenQueries(n,ids);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void DeleteQueries(GLsizei n, const GLuint* ids)
- {
-#if DALI_GLES_VERSION >= 30
- glDeleteQueries(n,ids);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- GLboolean IsQuery(GLuint id)
- {
-#if DALI_GLES_VERSION >= 30
- return glIsQuery(id);
-#else
- return 0;
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void BeginQuery(GLenum target, GLuint id)
- {
-#if DALI_GLES_VERSION >= 30
- glBeginQuery(target,id);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void EndQuery(GLenum target)
- {
-#if DALI_GLES_VERSION >= 30
- glEndQuery(target);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetQueryiv(GLenum target, GLenum pname, GLint* params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetQueryiv(target,pname,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetQueryObjectuiv(id,pname,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- GLboolean UnmapBuffer(GLenum target)
- {
-#if DALI_GLES_VERSION >= 30
- return glUnmapBuffer(target);
-#else
- return 0;
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetBufferPointerv(target,pname,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void DrawBuffers(GLsizei n, const GLenum* bufs)
- {
-#if DALI_GLES_VERSION >= 30
- glDrawBuffers(n,bufs);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
-#if DALI_GLES_VERSION >= 30
- glUniformMatrix2x3fv(location,count,transpose,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
-#if DALI_GLES_VERSION >= 30
- glUniformMatrix3x2fv(location,count,transpose,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
-#if DALI_GLES_VERSION >= 30
- glUniformMatrix2x4fv(location,count,transpose,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
-#if DALI_GLES_VERSION >= 30
- glUniformMatrix4x2fv(location,count,transpose,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
-#if DALI_GLES_VERSION >= 30
- glUniformMatrix3x4fv(location,count,transpose,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
-#if DALI_GLES_VERSION >= 30
- glUniformMatrix4x3fv(location,count,transpose,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
- {
-#if DALI_GLES_VERSION >= 30
- glBlitFramebuffer(srcX0,srcY0,srcX1,srcY1,dstX0,dstY0,dstX1,dstY1,mask,filter);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
- {
-#if DALI_GLES_VERSION >= 30
- glRenderbufferStorageMultisample(target,samples,internalformat,width,height);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
- {
-#if DALI_GLES_VERSION >= 30
- glFramebufferTextureLayer(target,attachment,texture,level,layer);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
- {
-#if DALI_GLES_VERSION >= 30
- return glMapBufferRange(target,offset,length,access);
-#else
- return NULL;
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
- {
-#if DALI_GLES_VERSION >= 30
- glFlushMappedBufferRange(target,offset,length);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void BindVertexArray(GLuint array)
- {
-#if DALI_GLES_VERSION >= 30
- glBindVertexArray(array);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
- {
-#if DALI_GLES_VERSION >= 30
- glDeleteVertexArrays(n,arrays);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GenVertexArrays(GLsizei n, GLuint* arrays)
- {
-#if DALI_GLES_VERSION >= 30
- glGenVertexArrays(n,arrays);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- GLboolean IsVertexArray(GLuint array)
- {
-#if DALI_GLES_VERSION >= 30
- return glIsVertexArray(array);
-#else
- return 0;
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
- {
-#if DALI_GLES_VERSION >= 30
- glGetIntegeri_v(target,index,data);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void BeginTransformFeedback(GLenum primitiveMode)
- {
-#if DALI_GLES_VERSION >= 30
- glBeginTransformFeedback(primitiveMode);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void EndTransformFeedback(void)
- {
-#if DALI_GLES_VERSION >= 30
- glEndTransformFeedback();
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
- {
-#if DALI_GLES_VERSION >= 30
- glBindBufferRange(target,index,buffer,offset,size);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
- {
-#if DALI_GLES_VERSION >= 30
- glBindBufferBase(target,index,buffer);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
- {
-#if DALI_GLES_VERSION >= 30
- glTransformFeedbackVaryings(program,count,varyings,bufferMode);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
- {
-#if DALI_GLES_VERSION >= 30
- glGetTransformFeedbackVarying(program,index,bufSize,length,size,type,name);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
- {
-#if DALI_GLES_VERSION >= 30
- glVertexAttribIPointer(index,size,type,stride,pointer);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetVertexAttribIiv(index,pname,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetVertexAttribIuiv(index,pname,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
- {
-#if DALI_GLES_VERSION >= 30
- glVertexAttribI4i(index,x,y,z,w);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
- {
-#if DALI_GLES_VERSION >= 30
- glVertexAttribI4ui(index,x,y,z,w);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void VertexAttribI4iv(GLuint index, const GLint* v)
- {
-#if DALI_GLES_VERSION >= 30
- glVertexAttribI4iv(index,v);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void VertexAttribI4uiv(GLuint index, const GLuint* v)
- {
-#if DALI_GLES_VERSION >= 30
- glVertexAttribI4uiv(index,v);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetUniformuiv(GLuint program, GLint location, GLuint* params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetUniformuiv(program,location,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- GLint GetFragDataLocation(GLuint program, const GLchar *name)
- {
-#if DALI_GLES_VERSION >= 30
- return glGetFragDataLocation(program,name);
-#else
- return -1;
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void Uniform1ui(GLint location, GLuint v0)
- {
-#if DALI_GLES_VERSION >= 30
- glUniform1ui(location,v0);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void Uniform2ui(GLint location, GLuint v0, GLuint v1)
- {
-#if DALI_GLES_VERSION >= 30
- glUniform2ui(location,v0,v1);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
- {
-#if DALI_GLES_VERSION >= 30
- glUniform3ui(location,v0,v1,v2);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
- {
-#if DALI_GLES_VERSION >= 30
- glUniform4ui(location,v0,v1,v2,v3);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
- {
-#if DALI_GLES_VERSION >= 30
- glUniform1uiv(location,count,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
- {
-#if DALI_GLES_VERSION >= 30
- glUniform2uiv(location,count,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
- {
-#if DALI_GLES_VERSION >= 30
- glUniform3uiv(location,count,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
- {
-#if DALI_GLES_VERSION >= 30
- glUniform4uiv(location,count,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
- {
-#if DALI_GLES_VERSION >= 30
- glClearBufferiv(buffer,drawbuffer,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
- {
-#if DALI_GLES_VERSION >= 30
- glClearBufferuiv(buffer,drawbuffer,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
- {
-#if DALI_GLES_VERSION >= 30
- glClearBufferfv(buffer,drawbuffer,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
- {
-#if DALI_GLES_VERSION >= 30
- glClearBufferfi(buffer,drawbuffer,depth,stencil);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- const GLubyte* GetStringi(GLenum name, GLuint index)
- {
-#if DALI_GLES_VERSION >= 30
- return glGetStringi(name,index);
-#else
- return NULL;
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
- {
-#if DALI_GLES_VERSION >= 30
- glCopyBufferSubData(readTarget,writeTarget,readOffset,writeOffset,size);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
- {
-#if DALI_GLES_VERSION >= 30
- glGetUniformIndices(program,uniformCount,uniformNames,uniformIndices);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetActiveUniformsiv(program,uniformCount,uniformIndices,pname,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
- {
-#if DALI_GLES_VERSION >= 30
- return glGetUniformBlockIndex(program,uniformBlockName);
-#else
- return 0;
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetActiveUniformBlockiv(program,uniformBlockIndex,pname,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
- {
-#if DALI_GLES_VERSION >= 30
- glGetActiveUniformBlockName(program,uniformBlockIndex,bufSize,length,uniformBlockName);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
- {
-#if DALI_GLES_VERSION >= 30
- glUniformBlockBinding(program,uniformBlockIndex,uniformBlockBinding);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
- {
-#if DALI_GLES_VERSION >= 30
- glDrawArraysInstanced(mode,first,count,instanceCount);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
- {
-#if DALI_GLES_VERSION >= 30
- glDrawElementsInstanced(mode,count,type,indices,instanceCount);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- GLsync FenceSync(GLenum condition, GLbitfield flags)
- {
-#if DALI_GLES_VERSION >= 30
- return glFenceSync(condition,flags);
-#else
- return NULL;
-#endif // DALI_GLES_VERSION >= 30
- }
-
- GLboolean IsSync(GLsync sync)
- {
-#if DALI_GLES_VERSION >= 30
- return glIsSync(sync);
-#else
- return 0;
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void DeleteSync(GLsync sync)
- {
-#if DALI_GLES_VERSION >= 30
- glDeleteSync(sync);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
- {
-#if DALI_GLES_VERSION >= 30
- return glClientWaitSync(sync,flags,timeout);
-#else
- return 0;
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
- {
-#if DALI_GLES_VERSION >= 30
- glWaitSync(sync,flags,timeout);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetInteger64v(GLenum pname, GLint64* params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetInteger64v(pname,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
- {
-#if DALI_GLES_VERSION >= 30
- glGetSynciv(sync,pname,bufSize,length,values);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
- {
-#if DALI_GLES_VERSION >= 30
- glGetInteger64i_v(target,index,data);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetBufferParameteri64v(target,pname,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GenSamplers(GLsizei count, GLuint* samplers)
- {
-#if DALI_GLES_VERSION >= 30
- glGenSamplers(count,samplers);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void DeleteSamplers(GLsizei count, const GLuint* samplers)
- {
-#if DALI_GLES_VERSION >= 30
- glDeleteSamplers(count,samplers);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- GLboolean IsSampler(GLuint sampler)
- {
-#if DALI_GLES_VERSION >= 30
- return glIsSampler(sampler);
-#else
- return 0;
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void BindSampler(GLuint unit, GLuint sampler)
- {
-#if DALI_GLES_VERSION >= 30
- glBindSampler(unit,sampler);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
- {
-#if DALI_GLES_VERSION >= 30
- glSamplerParameteri(sampler,pname,param);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
- {
-#if DALI_GLES_VERSION >= 30
- glSamplerParameteriv(sampler,pname,param);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
- {
-#if DALI_GLES_VERSION >= 30
- glSamplerParameterf(sampler,pname,param);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
- {
-#if DALI_GLES_VERSION >= 30
- glSamplerParameterfv(sampler,pname,param);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetSamplerParameteriv(sampler,pname,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetSamplerParameterfv(sampler,pname,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void VertexAttribDivisor(GLuint index, GLuint divisor)
- {
-#if DALI_GLES_VERSION >= 30
- glVertexAttribDivisor(index,divisor);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void BindTransformFeedback(GLenum target, GLuint id)
- {
-#if DALI_GLES_VERSION >= 30
- glBindTransformFeedback(target,id);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
- {
-#if DALI_GLES_VERSION >= 30
- glDeleteTransformFeedbacks(n,ids);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GenTransformFeedbacks(GLsizei n, GLuint* ids)
- {
-#if DALI_GLES_VERSION >= 30
- glGenTransformFeedbacks(n,ids);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- GLboolean IsTransformFeedback(GLuint id)
- {
-#if DALI_GLES_VERSION >= 30
- return glIsTransformFeedback(id);
-#else
- return 0;
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void PauseTransformFeedback(void)
- {
-#if DALI_GLES_VERSION >= 30
- glPauseTransformFeedback();
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void ResumeTransformFeedback(void)
- {
-#if DALI_GLES_VERSION >= 30
- glResumeTransformFeedback();
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
- {
-#if DALI_GLES_VERSION >= 30
- // if OpenGL ES 2.0 compatibility is need this can be implemented with
- // glGetProgramBinaryOES
- glGetProgramBinary(program,bufSize,length,binaryFormat,binary);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
- {
-#if DALI_GLES_VERSION >= 30
- // if OpenGL ES 2.0 compatibility is need this can be implemented with
- // glProgramBinaryOES
- glProgramBinary(program,binaryFormat,binary,length);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void ProgramParameteri(GLuint program, GLenum pname, GLint value)
- {
-#if DALI_GLES_VERSION >= 30
- glProgramParameteri(program,pname,value);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
- {
-#if DALI_GLES_VERSION >= 30
- // if OpenGL ES 2.0 compatibility is need this can be implemented with
- // glDiscardFramebufferEXT
- glInvalidateFramebuffer(target,numAttachments,attachments);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
- {
-#if DALI_GLES_VERSION >= 30
- glInvalidateSubFramebuffer(target,numAttachments,attachments,x,y,width,height);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
- {
-#if DALI_GLES_VERSION >= 30
- glTexStorage2D(target,levels,internalformat,width,height);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
- {
-#if DALI_GLES_VERSION >= 30
- glTexStorage3D(target,levels,internalformat,width,height,depth);
-#endif // DALI_GLES_VERSION >= 30
- }
-
- void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
- {
-#if DALI_GLES_VERSION >= 30
- glGetInternalformativ(target,internalformat,pname,bufSize,params);
-#endif // DALI_GLES_VERSION >= 30
- }
-
-private:
- ECoreX::GlExtensions mGlExtensions;
-
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_GL_IMPLEMENTATION_H__
+++ /dev/null
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-// CLASS HEADER
-#include "gl-proxy-implementation.h"
-
-// EXTERNAL INCLUDES
-#include <math.h>
-
-// INTERNAL INCLUDES
-#include <base/environment-options.h>
-#include <dali/integration-api/debug.h>
-
-namespace
-{
-const int NUM_FRAMES_PER_SECOND(60);
-}
-
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-Sampler::Sampler( const char* description )
-: mDescription( description ),
- mAccumulated(0.0f),
- mAccumulatedSquare(0.0f),
- mMin(0.0f),
- mMax(0.0f),
- mNumSamples(0),
- mCurrentFrameCount(0)
-{
-}
-
-void Sampler::Increment()
-{
- mCurrentFrameCount++;
-}
-
-void Sampler::Reset()
-{
- mAccumulated = 0.0f;
- mAccumulatedSquare= 0.0f;
- mMin = 0.0f;
- mMax = 0.0f;
- mNumSamples = 0;
- mCurrentFrameCount = 0;
-}
-
-void Sampler::Accumulate()
-{
- if( mNumSamples == 0 )
- {
- mMin = mCurrentFrameCount;
- mMax = mCurrentFrameCount;
- }
- else
- {
- if(mCurrentFrameCount < mMin)
- {
- mMin = mCurrentFrameCount;
- }
- if(mCurrentFrameCount > mMax)
- {
- mMax = mCurrentFrameCount;
- }
- }
-
- mNumSamples++;
-
- mAccumulated += mCurrentFrameCount;
- mAccumulatedSquare += (mCurrentFrameCount * mCurrentFrameCount);
- mCurrentFrameCount = 0;
-}
-const char* Sampler::GetDescription() const
-{
- return mDescription;
-}
-
-float Sampler::GetMeanValue() const
-{
- float meanValue = 0;
- if( mNumSamples > 0 )
- {
- meanValue = mAccumulated / (float)mNumSamples;
- }
- return meanValue;
-}
-
-float Sampler::GetStandardDeviation() const
-{
- float standardDeviation=0.0f;
- if( mNumSamples > 0 )
- {
- standardDeviation = sqrtf( mNumSamples * mAccumulatedSquare - (mAccumulated*mAccumulated)) / mNumSamples;
- }
- return standardDeviation;
-}
-
-float Sampler::GetMin() const
-{
- return mMin;
-}
-
-float Sampler::GetMax() const
-{
- return mMax;
-}
-
-GlProxyImplementation::GlProxyImplementation(EnvironmentOptions& environmentOptions)
-: mEnvironmentOptions(environmentOptions),
- mClearSampler("Clear calls"),
- mBindBufferSampler( "Bind buffers"),
- mBindTextureSampler( "Bind textures"),
- mDrawSampler("Draw calls"),
- mUniformSampler("Uniform sets"),
- mUseProgramSampler("Used programs"),
- mDrawCount(0),
- mUniformCount(0),
- mFrameCount(0)
-{
-}
-
-GlProxyImplementation::~GlProxyImplementation()
-{
-}
-
-void GlProxyImplementation::PreRender()
-{
-}
-
-void GlProxyImplementation::PostRender( unsigned int timeDelta )
-{
- // Accumulate counts in each sampler
- AccumulateSamples();
-
- // When we reach the desired frame count, output the averages from the samples
- mFrameCount++;
- if( mFrameCount >= mEnvironmentOptions.GetGlesCallTime() * NUM_FRAMES_PER_SECOND )
- {
- LogResults();
- ResetSamplers();
- }
-}
-
-void GlProxyImplementation::Clear( GLbitfield mask )
-{
- mClearSampler.Increment();
- GlImplementation::Clear(mask);
-}
-
-void GlProxyImplementation::BindBuffer( GLenum target, GLuint buffer )
-{
- mBindBufferSampler.Increment();
- GlImplementation::BindBuffer(target,buffer);
-}
-
-void GlProxyImplementation::BindTexture( GLenum target, GLuint texture )
-{
- mBindTextureSampler.Increment();
- GlImplementation::BindTexture(target,texture);
-}
-
-void GlProxyImplementation::DrawArrays( GLenum mode, GLint first, GLsizei count )
-{
- mDrawSampler.Increment();
- GlImplementation::DrawArrays(mode,first,count);
-}
-
-void GlProxyImplementation::DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices )
-{
- mDrawSampler.Increment();
- GlImplementation::DrawElements(mode,count,type,indices);
-}
-
-void GlProxyImplementation::Uniform1f( GLint location, GLfloat x )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform1f(location,x);
-}
-
-void GlProxyImplementation::Uniform1fv( GLint location, GLsizei count, const GLfloat* v )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform1fv(location,count,v);
-}
-
-void GlProxyImplementation::Uniform1i( GLint location, GLint x )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform1i(location,x);
-}
-
-void GlProxyImplementation::Uniform1iv( GLint location, GLsizei count, const GLint* v )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform1iv(location,count,v);
-}
-
-void GlProxyImplementation::Uniform2f( GLint location, GLfloat x, GLfloat y)
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform2f(location,x,y);
-}
-
-void GlProxyImplementation::Uniform2fv( GLint location, GLsizei count, const GLfloat* v )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform2fv(location,count,v);
-}
-
-void GlProxyImplementation::Uniform2i( GLint location, GLint x, GLint y )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform2i(location,x,y);
-}
-
-void GlProxyImplementation::Uniform2iv( GLint location, GLsizei count, const GLint* v )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform2iv(location,count,v);
-}
-
-void GlProxyImplementation::Uniform3f( GLint location, GLfloat x, GLfloat y, GLfloat z)
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform3f(location,x,y,z);
-}
-
-void GlProxyImplementation::Uniform3fv( GLint location, GLsizei count, const GLfloat* v )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform3fv(location,count,v);
-}
-
-void GlProxyImplementation::Uniform3i( GLint location, GLint x, GLint y, GLint z )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform3i(location,x,y,z);
-}
-
-void GlProxyImplementation::Uniform3iv( GLint location, GLsizei count, const GLint* v )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform3iv(location,count,v);
-}
-
-void GlProxyImplementation::Uniform4f( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform4f(location,x,y,z,w);
-}
-
-void GlProxyImplementation::Uniform4fv( GLint location, GLsizei count, const GLfloat* v )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform4fv(location,count,v);
-}
-
-void GlProxyImplementation::Uniform4i( GLint location, GLint x, GLint y, GLint z, GLint w )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform4i(location,x,y,z,w);
-}
-
-void GlProxyImplementation::Uniform4iv( GLint location, GLsizei count, const GLint* v )
-{
- mUniformSampler.Increment();
- GlImplementation::Uniform4iv(location,count,v);
-}
-
-void GlProxyImplementation::UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
-{
- mUniformSampler.Increment();
- GlImplementation::UniformMatrix2fv(location,count,transpose,value);
-}
-
-void GlProxyImplementation::UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
-{
- mUniformSampler.Increment();
- GlImplementation::UniformMatrix3fv(location,count,transpose,value);
-}
-
-void GlProxyImplementation::UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
-{
- mUniformSampler.Increment();
- GlImplementation::UniformMatrix4fv(location,count,transpose,value);
-}
-
-void GlProxyImplementation::UseProgram( GLuint program )
-{
- mUseProgramSampler.Increment();
- GlImplementation::UseProgram(program);
-}
-
-void GlProxyImplementation::AccumulateSamples()
-{
- // Accumulate counts in each sampler
- mClearSampler.Accumulate();
- mBindBufferSampler.Accumulate();
- mBindTextureSampler.Accumulate();
- mDrawSampler.Accumulate();
- mUniformSampler.Accumulate();
- mUseProgramSampler.Accumulate();
-}
-
-void GlProxyImplementation::LogResults()
-{
- Debug::LogMessage( Debug::DebugInfo, "OpenGL ES statistics sampled over %d frames) operations per frame:\n", mFrameCount );
- LogCalls( mClearSampler );
- LogCalls( mBindBufferSampler );
- LogCalls( mBindTextureSampler );
- LogCalls( mDrawSampler );
- LogCalls( mUniformSampler );
- LogCalls( mUseProgramSampler );
-}
-
-void GlProxyImplementation::LogCalls( const Sampler& sampler )
-{
- Debug::LogMessage( Debug::DebugInfo, " %s : Mean %5.2f (Min:%5.2f, Max:%5.2f, StdDev:%5.2f)\n",
- sampler.GetDescription(),
- sampler.GetMeanValue(), sampler.GetMin(), sampler.GetMax(),
- sampler.GetStandardDeviation() );
-}
-
-void GlProxyImplementation::ResetSamplers()
-{
- mClearSampler.Reset();
- mBindBufferSampler.Reset();
- mBindTextureSampler.Reset();
- mDrawSampler.Reset();
- mUniformSampler.Reset();
- mUseProgramSampler.Reset();
- mFrameCount = 0;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H__
-#define __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-
-#include <internal/common/gl/gl-implementation.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-class EnvironmentOptions;
-
-/**
- * Helper class to calculate the statistics for Open GLES calls
- */
-class Sampler
-{
-public:
-
- /**
- * Constructor
- * @param description to write to the log
- */
- Sampler( const char* description );
-
- /**
- * Increment the counter for this frame
- */
- void Increment();
-
- /**
- * Reset the counter
- */
- void Reset();
-
- /**
- * Accumulate the count onto statistics
- */
- void Accumulate();
-
- /**
- * @return the description of the sampler
- */
- const char* GetDescription() const;
-
- /**
- * @return the mean value
- */
- float GetMeanValue() const;
-
- /**
- * @return the standard deviation
- */
- float GetStandardDeviation() const;
-
- /**
- * @return the minimum value
- */
- float GetMin() const;
-
- /**
- * @return the maximum value
- */
- float GetMax() const;
-
-private: // Data
-
- const char* mDescription;
- float mAccumulated;
- float mAccumulatedSquare;
- float mMin;
- float mMax;
- unsigned int mNumSamples;
- unsigned int mCurrentFrameCount;
-};
-
-/**
- * GlProxyImplementation is a wrapper for the concrete implementation
- * of GlAbstraction that also gathers statistical information.
- */
-class GlProxyImplementation : public GlImplementation
-{
-public:
-
- /**
- * Constructor
- * @param environmentOptions to check how often to log results
- */
- GlProxyImplementation(EnvironmentOptions& environmentOptions);
-
- /**
- * Virtual destructor
- */
- virtual ~GlProxyImplementation();
-
- /**
- * @copydoc GlAbstraction::PreRender();
- */
- virtual void PreRender();
-
- /**
- * @copydoc GlAbstraction::PostRender();
- */
- virtual void PostRender( unsigned int timeDelta );
-
- /* OpenGL ES 2.0 API */
- virtual void Clear( GLbitfield mask );
-
- virtual void BindBuffer( GLenum target, GLuint buffer );
- virtual void BindTexture( GLenum target, GLuint texture );
-
- virtual void DrawArrays( GLenum mode, GLint first, GLsizei count );
- virtual void DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices );
-
- virtual void Uniform1f ( GLint location, GLfloat x );
- virtual void Uniform1fv( GLint location, GLsizei count, const GLfloat* v );
- virtual void Uniform1i ( GLint location, GLint x );
- virtual void Uniform1iv( GLint location, GLsizei count, const GLint* v );
- virtual void Uniform2f ( GLint location, GLfloat x, GLfloat y );
- virtual void Uniform2fv( GLint location, GLsizei count, const GLfloat* v );
- virtual void Uniform2i ( GLint location, GLint x, GLint y );
- virtual void Uniform2iv( GLint location, GLsizei count, const GLint* v );
- virtual void Uniform3f ( GLint location, GLfloat x, GLfloat y, GLfloat z );
- virtual void Uniform3fv( GLint location, GLsizei count, const GLfloat* v );
- virtual void Uniform3i ( GLint location, GLint x, GLint y, GLint z );
- virtual void Uniform3iv( GLint location, GLsizei count, const GLint* v );
- virtual void Uniform4f ( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
- virtual void Uniform4fv( GLint location, GLsizei count, const GLfloat* v );
- virtual void Uniform4i ( GLint location, GLint x, GLint y, GLint z, GLint w );
- virtual void Uniform4iv( GLint location, GLsizei count, const GLint* v );
- virtual void UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
- virtual void UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
- virtual void UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value );
-
- virtual void UseProgram( GLuint program );
-
-private: // Helpers
-
- void AccumulateSamples();
- void LogResults();
- void LogCalls( const Sampler& sampler );
- void ResetSamplers();
-
-private: // Data
-
- EnvironmentOptions& mEnvironmentOptions;
- Sampler mClearSampler;
- Sampler mBindBufferSampler;
- Sampler mBindTextureSampler;
- Sampler mDrawSampler;
- Sampler mUniformSampler;
- Sampler mUseProgramSampler;
- int mDrawCount;
- int mUniformCount;
- int mFrameCount;
-
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <internal/common/haptic-player-impl.h>
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace // unnamed namespace
-{
-
-// Type Registration
-Dali::BaseHandle Create()
-{
- return HapticPlayer::Get();
-}
-
-Dali::TypeRegistration HAPTIC_PLAYER_TYPE( typeid(Dali::HapticPlayer), typeid(Dali::BaseHandle), Create );
-
-} // unnamed namespace
-
-Dali::HapticPlayer HapticPlayer::New()
-{
- Dali::HapticPlayer player = Dali::HapticPlayer( new HapticPlayer() );
- return player;
-}
-
-Dali::HapticPlayer HapticPlayer::Get()
-{
- Dali::HapticPlayer player;
-
- if ( Adaptor::IsAvailable() )
- {
- // Check whether the singleton is already created
- Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::HapticPlayer ) );
- if ( handle )
- {
- // If so, downcast the handle
- player = Dali::HapticPlayer( dynamic_cast< HapticPlayer* >( handle.GetObjectPtr() ) );
- }
- else
- {
- Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
- player = Dali::HapticPlayer( New() );
- adaptorImpl.RegisterSingleton( typeid( player ), player );
- }
- }
-
- return player;
-}
-
-void HapticPlayer::PlayMonotone( unsigned int duration )
-{
- mPlugin.PlayHapticMonotone( duration );
-}
-
-void HapticPlayer::PlayFile( const std::string& filePath )
-{
- mPlugin.PlayHaptic( filePath );
-}
-
-void HapticPlayer::Stop()
-{
- mPlugin.StopHaptic();
-}
-
-HapticPlayer::HapticPlayer()
-: mPlugin( FeedbackPluginProxy::DEFAULT_OBJECT_NAME )
-{
-}
-
-HapticPlayer::~HapticPlayer()
-{
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_HAPTIC_PLAYER_H__
-#define __DALI_INTERNAL_HAPTIC_PLAYER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/adaptor-framework/common/haptic-player.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/feedback/feedback-plugin-proxy.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class FeedbackPluginProxy;
-
-/**
- * Plays haptic effects.
- */
-class HapticPlayer : public Dali::BaseObject
-{
-
-public:
-
- /**
- * Create a HapticPlayer.
- * This should only be called once by the Adaptor class.
- * @return A newly created HapticPlayer.
- */
- static Dali::HapticPlayer New();
-
- /**
- * Retrieve a handle to the HapticPlayer. This creates an instance if none has been created.
- * @return A handle to the HapticPlayer.
- */
- static Dali::HapticPlayer Get();
-
- /**
- * @copydoc Dali::HapticPlayer::PlayMonotone()
- */
- void PlayMonotone(unsigned int duration);
-
- /**
- * @copydoc Dali::HapticPlayer::PlayFile()
- */
- void PlayFile( const std::string& filePath );
-
- /**
- * @copydoc Dali::HapticPlayer::Stop()
- */
- void Stop();
-
-private:
-
- /**
- * Private Constructor; see also HapticPlayer::New()
- */
- HapticPlayer();
-
- /**
- * Virtual Destructor
- */
- virtual ~HapticPlayer();
-
- // Undefined
- HapticPlayer(const HapticPlayer&);
-
- // Undefined
- HapticPlayer& operator=(HapticPlayer&);
-
-private:
-
- FeedbackPluginProxy mPlugin;
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-
-inline Internal::Adaptor::HapticPlayer& GetImplementation(Dali::HapticPlayer& player)
-{
- DALI_ASSERT_ALWAYS( player && "HapticPlayer handle is empty" );
-
- BaseObject& handle = player.GetBaseObject();
-
- return static_cast<Internal::Adaptor::HapticPlayer&>(handle);
-}
-
-inline const Internal::Adaptor::HapticPlayer& GetImplementation(const Dali::HapticPlayer& player)
-{
- DALI_ASSERT_ALWAYS( player && "HapticPlayer handle is empty" );
-
- const BaseObject& handle = player.GetBaseObject();
-
- return static_cast<const Internal::Adaptor::HapticPlayer&>(handle);
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_HAPTIC_PLAYER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <internal/common/imf-manager-impl.h>
-
-// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
-#include <dali/public-api/events/key-event.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/adaptor-framework/common/adaptor.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/ecore-x/window-render-surface.h>
-#include <internal/common/adaptor-impl.h>
-#include <internal/common/virtual-keyboard-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_IMF_MANAGER");
-#endif
-
-// Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead.
-size_t Utf8SequenceLength(const unsigned char leadByte)
-{
- size_t length = 0;
-
- if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero)
- {
- length = 1;
- }
- else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
- {
- length = 2;
- }
- else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
- {
- length = 3;
- }
- else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
- {
- length = 4;
- }
-
- return length;
-}
-
-// Static function calls used by ecore 'c' style callback registration
-void Commit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
-{
- if ( data )
- {
- ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
- imfManager->CommitReceived( data, imfContext, event_info );
- }
-}
-
-void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
-{
- if ( data )
- {
- ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
- imfManager->PreEditChanged( data, imfContext, event_info );
- }
-}
-
-Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
-{
- if ( data )
- {
- ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
- return imfManager->RetrieveSurrounding( data, imfContext, text, cursorPosition );
- }
- else
- {
- return false;
- }
-}
-
-/**
- * Called when an IMF delete surrounding event is received.
- * Here we tell the application that it should delete a certain range.
- */
-void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
-{
- if ( data )
- {
- ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
- imfManager->DeleteSurrounding( data, imfContext, event_info );
- }
-}
-
-BaseHandle Create()
-{
- BaseHandle handle( ImfManager::Get() );
-
- if ( !handle && Adaptor::IsAvailable() )
- {
- Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
-
- // The Ecore_X_Window needs to use the ImfManager.
- // Only when the render surface is window, we can get the Ecore_X_Window.
- Ecore_X_Window ecoreXwin( 0 );
- Dali::RenderSurface& surface( adaptorImpl.GetSurface() );
- if( surface.GetType() == Dali::RenderSurface::WINDOW )
- {
- ecoreXwin = AnyCast< Ecore_X_Window >( adaptorImpl.GetSurface().GetSurface() );
- }
-
- // If we fail to get Ecore_X_Window, we can't use the ImfManager correctly.
- // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
- // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
-
- Dali::ImfManager manager = Dali::ImfManager( new ImfManager( ecoreXwin ) );
- adaptorImpl.RegisterSingleton( typeid( manager ), manager );
- handle = manager;
- }
-
- return handle;
-}
-
-TypeRegistration IMF_MANAGER_TYPE( typeid(Dali::ImfManager), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
-
-} // unnamed namespace
-
-Dali::ImfManager ImfManager::Get()
-{
- Dali::ImfManager manager;
-
- if ( Adaptor::IsAvailable() )
- {
- // Check whether the singleton is already created
- Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::ImfManager ) );
- if(handle)
- {
- // If so, downcast the handle
- manager = Dali::ImfManager( dynamic_cast< ImfManager* >( handle.GetObjectPtr() ) );
- }
- }
-
- return manager;
-}
-
-ImfManager::ImfManager( Ecore_X_Window ecoreXwin )
-: mIMFContext(),
- mIMFCursorPosition( 0 ),
- mSurroundingText(""),
- mRestoreAfterFocusLost( false ),
- mIdleCallbackConnected( false ),
- mKeyEvents()
-{
- ecore_imf_init();
- CreateContext( ecoreXwin );
-
- ConnectCallbacks();
- VirtualKeyboard::ConnectCallbacks( mIMFContext );
-}
-
-ImfManager::~ImfManager()
-{
- VirtualKeyboard::DisconnectCallbacks( mIMFContext );
- DisconnectCallbacks();
-
- DeleteContext();
- ecore_imf_shutdown();
-}
-
-void ImfManager::CreateContext( Ecore_X_Window ecoreXwin )
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CreateContext\n" );
-
- const char *contextId = ecore_imf_context_default_id_get();
- if( contextId )
- {
- mIMFContext = ecore_imf_context_add( contextId );
-
- if( mIMFContext )
- {
- if( ecoreXwin )
- {
- ecore_imf_context_client_window_set( mIMFContext, reinterpret_cast<void*>( ecoreXwin ) );
- }
- }
- else
- {
- DALI_LOG_WARNING("IMF Unable to get IMF Context\n");
- }
- }
- else
- {
- DALI_LOG_WARNING("IMF Unable to get IMF Context\n");
- }
-}
-
-void ImfManager::DeleteContext()
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteContext\n" );
-
- if ( mIMFContext )
- {
- mIMFContext = NULL;
- }
-}
-
-// Callbacks for predicitive text support.
-void ImfManager::ConnectCallbacks()
-{
- if ( mIMFContext )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::ConnectCallbacks\n" );
-
- ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this );
- ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this );
- ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this );
-
- ecore_imf_context_retrieve_surrounding_callback_set( mIMFContext, ImfRetrieveSurrounding, this);
- }
-}
-
-void ImfManager::DisconnectCallbacks()
-{
- if ( mIMFContext )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DisconnectCallbacks\n" );
-
- ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit );
- ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit );
- ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding );
-
- // We do not need to unset the retrieve surrounding callback.
- }
-}
-
-void ImfManager::Activate()
-{
- // Reset mIdleCallbackConnected
- mIdleCallbackConnected = false;
-
- if ( mIMFContext )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Activate\n" );
-
- ecore_imf_context_focus_in( mIMFContext );
-
- // emit keyboard activated signal
- Dali::ImfManager handle( this );
- mActivatedSignalV2.Emit( handle );
- }
-}
-
-void ImfManager::Deactivate()
-{
- if( mIMFContext )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Deactivate\n" );
-
- Reset();
- ecore_imf_context_focus_out( mIMFContext );
- }
-
- // Reset mIdleCallbackConnected
- mIdleCallbackConnected = false;
-}
-
-void ImfManager::Reset()
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Reset\n" );
-
- if ( mIMFContext )
- {
- ecore_imf_context_reset( mIMFContext );
- }
-}
-
-Ecore_IMF_Context* ImfManager::GetContext()
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetContext\n" );
-
- return mIMFContext;
-}
-
-bool ImfManager::RestoreAfterFocusLost() const
-{
- return mRestoreAfterFocusLost;
-}
-
-void ImfManager::SetRestoreAferFocusLost( bool toggle )
-{
- mRestoreAfterFocusLost = toggle;
-}
-
-/**
- * Called when an IMF Pre-Edit changed event is received.
- * We are still predicting what the user is typing. The latest string is what the IMF module thinks
- * the user wants to type.
- */
-void ImfManager::PreEditChanged( void *, Ecore_IMF_Context *imfContext, void *event_info )
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::PreEditChanged\n" );
-
- char *preEditString( NULL );
- int cursorPosition( 0 );
- Eina_List *attrs = NULL;
- Eina_List *l = NULL;
-
- Ecore_IMF_Preedit_Attr *attr;
-
- // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.
- // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.
- ecore_imf_context_preedit_string_with_attributes_get( imfContext, &preEditString, &attrs, &cursorPosition );
-
- if ( attrs )
- {
- // iterate through the list of attributes getting the type, start and end position.
- for ( l = attrs, (attr = (Ecore_IMF_Preedit_Attr*)eina_list_data_get(l) ); l; l = eina_list_next(l), ( attr = (Ecore_IMF_Preedit_Attr*)eina_list_data_get(l) ))
- {
- if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF)
- {
- // check first byte so know how many bytes a character is represented by as keyboard returns cursor position in bytes. Which is different for some languages.
-
- size_t visualCharacterIndex = 0;
- size_t byteIndex = 0;
-
- // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
- while ( preEditString[byteIndex] != '\0' )
- {
- // attr->end_index is provided as a byte position not character and we need to know the character position.
- size_t currentSequenceLength = Utf8SequenceLength(preEditString[byteIndex]); // returns number of bytes used to represent character.
- if ( byteIndex == attr->end_index )
- {
- cursorPosition = visualCharacterIndex;
- break;
- // end loop as found cursor position that matches byte position
- }
- else
- {
- byteIndex += currentSequenceLength; // jump to next character
- visualCharacterIndex++; // increment character count so we know our position for when we get a match
- }
-
- DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString ));
- }
- }
- }
- }
-
- if ( Dali::Adaptor::IsAvailable() )
- {
- std::string keyString ( preEditString );
- int numberOfChars( 0 );
-
- Dali::ImfManager handle( this );
- Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::PREEDIT, keyString, cursorPosition, numberOfChars );
- Dali::ImfManager::ImfCallbackData callbackData = mEventSignalV2.Emit( handle, imfEventData );
-
- if ( callbackData.update )
- {
- SetCursorPosition( callbackData.cursorPosition );
- SetSurroundingText( callbackData.currentText );
-
- NotifyCursorPosition();
- }
-
- if ( callbackData.preeditResetRequired )
- {
- Reset();
- }
- }
- free( preEditString );
-}
-
-void ImfManager::CommitReceived( void *, Ecore_IMF_Context *imfContext, void *event_info )
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CommitReceived\n" );
-
- if ( Dali::Adaptor::IsAvailable() )
- {
- const std::string keyString( (char *)event_info );
- const int cursorOffset( 0 );
- const int numberOfChars( 0 );
-
- Dali::ImfManager handle( this );
- Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::COMMIT, keyString, cursorOffset, numberOfChars );
- Dali::ImfManager::ImfCallbackData callbackData = mEventSignalV2.Emit( handle, imfEventData );
-
- if ( callbackData.update )
- {
- SetCursorPosition( callbackData.cursorPosition );
- SetSurroundingText( callbackData.currentText );
-
- NotifyCursorPosition();
- }
- }
-}
-
-/**
- * Called when an IMF retrieve surround event is received.
- * Here the IMF module wishes to know the string we are working with and where within the string the cursor is
- * We need to signal the application to tell us this information.
- */
-Eina_Bool ImfManager::RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::RetrieveSurrounding\n" );
-
- std::string keyString ( "" );
- int cursorOffset( 0 );
- int numberOfChars( 0 );
-
- Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::GETSURROUNDING , keyString, cursorOffset, numberOfChars );
- Dali::ImfManager handle( this );
- mEventSignalV2.Emit( handle, imfData );
-
- if ( text )
- {
- std::string surroundingText( GetSurroundingText() );
-
- if ( !surroundingText.empty() )
- {
- *text = strdup( surroundingText.c_str() );
- }
- else
- {
- *text = strdup( "" );
- }
- }
-
- if ( cursorPosition )
- {
- *cursorPosition = GetCursorPosition();
- }
-
-
- return EINA_TRUE;
-}
-
-/**
- * Called when an IMF delete surrounding event is received.
- * Here we tell the application that it should delete a certain range.
- */
-void ImfManager::DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteSurrounding\n" );
-
- if ( Dali::Adaptor::IsAvailable() )
- {
- Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = (Ecore_IMF_Event_Delete_Surrounding*) event_info;
-
- const std::string keyString( "" );
- const int cursorOffset( deleteSurroundingEvent->offset );
- const int numberOfChars( deleteSurroundingEvent->n_chars );
-
- Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::DELETESURROUNDING , keyString, cursorOffset, numberOfChars );
- Dali::ImfManager handle( this );
- mEventSignalV2.Emit( handle, imfData );
- }
-}
-
-void ImfManager::NotifyCursorPosition()
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::NotifyCursorPosition\n" );
-
- if ( mIMFContext )
- {
- ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
- }
-}
-
-int ImfManager::GetCursorPosition()
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetCursorPosition\n" );
-
- return mIMFCursorPosition;
-}
-
-void ImfManager::SetCursorPosition( unsigned int cursorPosition )
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetCursorPosition\n" );
-
- mIMFCursorPosition = ( int )cursorPosition;
-}
-
-void ImfManager::SetSurroundingText( std::string text )
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetSurroundingText\n" );
-
- mSurroundingText = text;
-}
-
-std::string ImfManager::GetSurroundingText()
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetSurroundingText\n" );
-
- return mSurroundingText;
-}
-
-} // Adaptor
-
-} // Internal
-
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_IMF_MANAGER_H
-#define __DALI_INTERNAL_IMF_MANAGER_H
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <Ecore_IMF.h>
-#include <Ecore_X.h>
-
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/adaptor-framework/common/imf-manager.h>
-#include <dali/integration-api/events/key-event-integ.h>
-
-// INTERNAL INCLUDES
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class RenderSurface;
-
-class ImfManager : public Dali::BaseObject
-{
-public:
- typedef Dali::ImfManager::ImfManagerSignalV2 ImfManagerSignalV2;
- typedef Dali::ImfManager::ImfEventSignalV2 ImfEventSignalV2;
-
-public:
-
- /**
- * Create the IMF manager.
- */
- static Dali::ImfManager Get();
-
- /**
- * Constructor
- * @param[in] ecoreXwin, The window is created by application.
- */
- ImfManager( Ecore_X_Window ecoreXwin );
-
- /**
- * Connect Callbacks required for IMF.
- * If you don't connect imf callbacks, you can't get the key events.
- * The events are PreeditChanged, Commit and DeleteSurrounding.
- */
- void ConnectCallbacks();
-
- /**
- * Disconnect Callbacks attached to imf context.
- */
- void DisconnectCallbacks();
-
- /**
- * @copydoc Dali::ImfManager::Activate()
- */
- void Activate();
-
- /**
- * @copydoc Dali::ImfManager::Deactivate()
- */
- void Deactivate();
-
- /**
- * @copydoc Dali::ImfManager::Reset()
- */
- void Reset();
-
- /**
- * @copydoc Dali::ImfManager::GetContext()
- */
- Ecore_IMF_Context* GetContext();
-
- /**
- * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
- */
- bool RestoreAfterFocusLost() const;
-
- /**
- * @copydoc Dali::ImfManager::SetRestoreAferFocusLost()
- */
- void SetRestoreAferFocusLost( bool toggle );
-
- /**
- * @copydoc Dali::ImfManager::PreEditChanged()
- */
- void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
-
- /**
- * @copydoc Dali::ImfManager::NotifyCursorPosition()
- */
- void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
-
- /**
- * @copydoc Dali::ImfManager::NotifyCursorPosition()
- */
- Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
-
- /**
- * @copydoc Dali::ImfManager::DeleteSurrounding()
- */
- void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
-
- // Cursor related
- /**
- * @copydoc Dali::ImfManager::NotifyCursorPosition()
- */
- void NotifyCursorPosition();
-
- /**
- * @copydoc Dali::ImfManager::GetCursorPosition()
- */
- int GetCursorPosition();
-
- /**
- * @copydoc Dali::ImfManager::SetCursorPosition()
- */
- void SetCursorPosition( unsigned int cursorPosition );
-
- /**
- * @copydoc Dali::ImfManager::SetSurroundingText()
- */
- void SetSurroundingText( std::string text );
-
- /**
- * @copydoc Dali::ImfManager::GetSurroundingText()
- */
- std::string GetSurroundingText();
-
-public: // Signals
-
- /**
- * @copydoc Dali::ImfManager::ActivatedSignal()
- */
- ImfManagerSignalV2& ActivatedSignal() { return mActivatedSignalV2; }
-
- /**
- * @copydoc Dali::ImfManager::EventReceivedSignal()
- */
- ImfEventSignalV2& EventReceivedSignal() { return mEventSignalV2; }
-
-protected:
-
- /**
- * Destructor.
- */
- virtual ~ImfManager();
-
-private:
- /**
- * Context created the first time and kept until deleted.
- * @param[in] ecoreXwin, The window is created by application.
- */
- void CreateContext( Ecore_X_Window ecoreXwin );
-
- /**
- * @copydoc Dali::ImfManager::DeleteContext()
- */
- void DeleteContext();
-
-private:
- // Undefined
- ImfManager( const ImfManager& );
- ImfManager& operator=( ImfManager& );
-
-private:
- Ecore_IMF_Context* mIMFContext;
- int mIMFCursorPosition;
- std::string mSurroundingText;
-
- bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
- bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
-
- std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
-
- ImfManagerSignalV2 mActivatedSignalV2;
- ImfEventSignalV2 mEventSignalV2;
-
-public:
-
-inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
-{
- DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
-
- BaseObject& handle = imfManager.GetBaseObject();
-
- return static_cast<Internal::Adaptor::ImfManager&>(handle);
-}
-
-inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
-{
- DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
-
- const BaseObject& handle = imfManager.GetBaseObject();
-
- return static_cast<const Internal::Adaptor::ImfManager&>(handle);
-}
-
-};
-
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_IMF_MANAGER_H
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "indicator-buffer.h"
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-IndicatorBuffer::IndicatorBuffer( Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pixelFormat )
-: mAdaptor(adaptor),
- mImageWidth(width),
- mImageHeight(height),
- mPixelFormat(pixelFormat)
-{
- DALI_ASSERT_ALWAYS( adaptor );
-
- // Use BitmapImage when SharedGlBuffer extension is unavailable
- mBitmapBuffer = new NativeBitmapBuffer( adaptor, mImageWidth, mImageHeight, mPixelFormat );
- mNativeImage = mBitmapBuffer;
-}
-
-bool IndicatorBuffer::UpdatePixels( const unsigned char *src, size_t size )
-{
- // Use double buffered bitmap when SharedGlBuffer extension is unavailable
- mBitmapBuffer->Write( src, size );
- return true;
-}
-
-NativeImage& IndicatorBuffer::GetNativeImage() const
-{
- DALI_ASSERT_DEBUG(mNativeImage.Get());
- return *mNativeImage;
-}
-
-void IndicatorBuffer::SetAdaptor( Adaptor* adaptor )
-{
- mAdaptor = adaptor;
-}
-
-} // Adaptor
-} // Internal
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_INDICATOR_BUFFER_H__
-#define __DALI_INTERNAL_INDICATOR_BUFFER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/native-bitmap-buffer-impl.h>
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-namespace Adaptor
-{
-
-class NativeBitmapBuffer;
-class IndicatorBuffer;
-
-typedef IntrusivePtr<IndicatorBuffer> IndicatorBufferPtr;
-
-/**
- * The IndicatorBuffer class uses the best available implementation for rendering indicator data.
- * On platforms where EglImage is available it uses either SharedGlBuffer or PixmapImage, on older
- * platforms it falls back to using a bitmap buffer based solution.
- */
-class IndicatorBuffer : public RefObject
-{
-public:
-
- /**
- * Constructor
- */
- IndicatorBuffer( Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pixelFormat );
-
- /**
- * Copy bitmap data to pixel buffer.
- * @param src bitmap data source
- * @param size size of bitmap data
- * @return true if successful, false otherwise
- */
- bool UpdatePixels( const unsigned char *src, size_t size );
-
- /**
- * Returns the NativeImage used internally
- * @return the NativeImage used internally
- */
- NativeImage& GetNativeImage() const;
-
- /**
- * Set currently used Adaptor
- * @param adaptor
- */
- void SetAdaptor( Adaptor* adaptor );
-
-private:
- NativeImagePtr mNativeImage; ///< Image buffer created for shared file copy
-
- NativeBitmapBufferPtr mBitmapBuffer; ///< Image buffer created for shared file copy if extension not available
-
- Adaptor* mAdaptor;
-
- int mImageWidth;
- int mImageHeight;
- Pixel::Format mPixelFormat;
-
- // Only used with fallback bitmap buffer implementation
- bool mUpdatingBitmap:1; ///< Whether BitmapImage is being uploaded to graphics memory
- bool mUpdateBitmapAgain:1; ///< Whether to update BitmapImage again after upload complete
-};
-
-} // Adaptor
-} // Internal
-} // Dali
-
-#endif // __DALI_INTERNAL_INDICATOR_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "indicator-impl.h"
-
-// EXTERNAL INCLUDES
-#include <Ecore.h>
-#include <Evas.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include <dali/public-api/images/bitmap-image.h>
-#include <dali/public-api/adaptor-framework/common/pixmap-image.h>
-#include <dali/public-api/actors/image-actor.h>
-#include <dali/public-api/events/touch-event.h>
-#include <dali/public-api/events/touch-point.h>
-#include <dali/public-api/common/stage.h>
-#include <dali/public-api/actors/blending.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
-
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/adaptor-impl.h>
-#include <internal/common/accessibility-manager-impl.h>
-
-using Dali::Vector4;
-
-#if defined(DEBUG_ENABLED)
-#define STATE_DEBUG_STRING(state) (state==DISCONNECTED?"DISCONNECTED":state==CONNECTED?"CONNECTED":"UNKNOWN")
-#endif
-
-namespace
-{
-
-const float SLIDING_ANIMATION_DURATION( 0.2f ); // 200 milli seconds
-const float AUTO_INDICATOR_STAY_DURATION(3.0f); // 3 seconds
-const float SHOWING_DISTANCE_HEIGHT_RATE(0.34f); // 20 pixels
-
-enum
-{
- KEEP_SHOWING = -1,
- HIDE_NOW = 0
-};
-
-const int NUM_GRADIENT_INTERVALS(5); // Number of gradient intervals
-const Dali::Vector4 GRADIENT_COLORS[NUM_GRADIENT_INTERVALS+1] =
-{
- Vector4(0.0f, 0.0f, 0.0f, 0.6f),
- Vector4(0.0f, 0.0f, 0.0f, 0.38f),
- Vector4(0.0f, 0.0f, 0.0f, 0.20f),
- Vector4(0.0f, 0.0f, 0.0f, 0.08f),
- Vector4(0.0f, 0.0f, 0.0f, 0.0f),
- Vector4(0.0f, 0.0f, 0.0f, 0.0f),
-};
-
-const float OPAQUE_THRESHOLD(0.99f);
-const float TRANSPARENT_THRESHOLD(0.05f);
-
-// Indicator orientation
-const char* ELM_INDICATOR_PORTRAIT("elm_indicator_portrait");
-const char* ELM_INDICATOR_LANDSCAPE("elm_indicator_landscape");
-const char* ELM_INDICATOR_PORTRAIT_FIXED_COLOR_STYLE("elm_indicator_portrait_fixed");
-const char* ELM_INDICATOR_LANDSCAPE_FIXED_COLOR_STYLE("elm_indicator_landscape_fixed");
-
-const char* MESH_VERTEX_SHADER =
-"attribute lowp vec3 aColor;\n"
-"varying mediump vec4 vColor;\n"
-"void main()\n"
-"{\n"
-" gl_Position = uMvpMatrix * vec4(aPosition, 1.0);\n"
-" vColor = vec4(aColor.r, aColor.g, aColor.b, aTexCoord.x);\n"
-"}\n";
-
-const char* MESH_FRAGMENT_SHADER =
-"varying mediump vec4 vColor;\n"
-"void main()\n"
-"{\n"
-" gl_FragColor = vColor*uColor;\n"
-"}\n";
-
-// Copied from elm_win.h
-
-/**
- * Defines the type modes of indicator that can be shown
- * If the indicator can support several type of indicator,
- * you can use this enum value to deal with different type of indicator
- */
-typedef enum
-{
- ELM_WIN_INDICATOR_TYPE_UNKNOWN, /**< Unknown indicator type mode */
- ELM_WIN_INDICATOR_TYPE_1, /**< Type 0 the the indicator */
- ELM_WIN_INDICATOR_TYPE_2, /**< Type 1 the indicator */
-} Elm_Win_Indicator_Type_Mode;
-
-// Copied from ecore_evas_extn.c
-
-enum // opcodes
-{
- OP_RESIZE,
- OP_SHOW,
- OP_HIDE,
- OP_FOCUS,
- OP_UNFOCUS,
- OP_UPDATE,
- OP_UPDATE_DONE,
- OP_LOCK_FILE,
- OP_SHM_REF,
- OP_EV_MOUSE_IN,
- OP_EV_MOUSE_OUT,
- OP_EV_MOUSE_UP,
- OP_EV_MOUSE_DOWN,
- OP_EV_MOUSE_MOVE,
- OP_EV_MOUSE_WHEEL,
- OP_EV_MULTI_UP,
- OP_EV_MULTI_DOWN,
- OP_EV_MULTI_MOVE,
- OP_EV_KEY_UP,
- OP_EV_KEY_DOWN,
- OP_EV_HOLD,
- OP_MSG_PARENT,
- OP_MSG,
- OP_PIXMAP_REF
-};
-
-// Copied from elm_conform.c
-
-const int MSG_DOMAIN_CONTROL_INDICATOR(0x10001);
-const int MSG_ID_INDICATOR_REPEAT_EVENT(0x10002);
-const int MSG_ID_INDICATOR_ROTATION(0x10003);
-const int MSG_ID_INDICATOR_OPACITY(0X1004);
-const int MSG_ID_INDICATOR_TYPE(0X1005);
-const int MSG_ID_INDICATOR_START_ANIMATION(0X10006);
-
-struct IpcDataUpdate
-{
- int x, w, y, h;
-};
-
-struct IpcDataResize
-{
- int w, h;
-};
-
-struct IpcIndicatorDataAnimation
-{
- unsigned int xwin;
- double duration;
-};
-
-struct IpcDataEvMouseUp
-{
- int b;
- Evas_Button_Flags flags;
- int mask;
- unsigned int timestamp;
- Evas_Event_Flags event_flags;
-
- IpcDataEvMouseUp(unsigned long timestamp)
- : b(1),
- flags(EVAS_BUTTON_NONE),
- mask(0),
- timestamp(static_cast<unsigned int>(timestamp)),
- event_flags(EVAS_EVENT_FLAG_NONE)
- {
- }
-};
-
-struct IpcDataEvMouseDown
-{
- int b;
- Evas_Button_Flags flags;
- int mask;
- unsigned int timestamp;
- Evas_Event_Flags event_flags;
-
- IpcDataEvMouseDown(unsigned long timestamp)
- : b(1),
- flags(EVAS_BUTTON_NONE),
- mask(0),
- timestamp(static_cast<unsigned int>(timestamp)),
- event_flags(EVAS_EVENT_FLAG_NONE)
- {
- }
-};
-
-struct IpcDataEvMouseMove
-{
- int x, y;
- Evas_Button_Flags flags;
- int mask;
- unsigned int timestamp;
- Evas_Event_Flags event_flags;
-
- IpcDataEvMouseMove(const Dali::TouchPoint& touchPoint, unsigned long timestamp)
- : x(static_cast<Evas_Coord>(touchPoint.local.x)),
- y(static_cast<Evas_Coord>(touchPoint.local.y)),
- flags(EVAS_BUTTON_NONE),
- mask(0),
- timestamp(static_cast<unsigned int>(timestamp)),
- event_flags(EVAS_EVENT_FLAG_NONE)
- {
- }
-};
-
-struct IpcDataEvMouseOut
-{
- unsigned int timestamp;
- int mask;
- Evas_Event_Flags event_flags;
-
- IpcDataEvMouseOut(unsigned long timestamp)
- : timestamp(static_cast<unsigned int>(timestamp)),
- mask(0),
- event_flags(EVAS_EVENT_FLAG_NONE)
- {
- }
-};
-
-void SetMeshDataColors(Dali::AnimatableMesh mesh, const Vector4 (&colors)[NUM_GRADIENT_INTERVALS+1])
-{
- for( size_t i=0; i<NUM_GRADIENT_INTERVALS+1; i++ )
- {
- int j=i*2;
- mesh[j].SetColor(colors[i]);
- mesh[j+1].SetColor(colors[i]);
- mesh[j].SetTextureCoords(Dali::Vector2(colors[i].a, colors[i].a));
- mesh[j+1].SetTextureCoords(Dali::Vector2(colors[i].a, colors[i].a));
- }
-}
-
-void SetMeshDataColors(Dali::AnimatableMesh mesh, const Vector4& color)
-{
- for( size_t i=0, length=NUM_GRADIENT_INTERVALS+1 ; i<length; i++ )
- {
- int j=i*2;
- mesh[j].SetColor(color);
- mesh[j+1].SetColor(color);
- mesh[j].SetTextureCoords(Dali::Vector2(color.a, color.a));
- mesh[j+1].SetTextureCoords(Dali::Vector2(color.a, color.a));
- }
-}
-
-} // anonymous namespace
-
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gIndicatorLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_INDICATOR");
-#endif
-
-
-Indicator::LockFile::LockFile(const char* filename)
-: mFilename(filename),
- mErrorThrown(false)
-{
- mFileDescriptor = open(filename, O_RDWR);
- if( mFileDescriptor == -1 )
- {
- mFileDescriptor = 0;
- mErrorThrown = true;
- DALI_LOG_ERROR( "### Cannot open %s for indicator lock ###\n", mFilename.c_str() );
- }
-}
-
-Indicator::LockFile::~LockFile()
-{
- // Closing file descriptor also unlocks file.
- close( mFileDescriptor );
-}
-
-bool Indicator::LockFile::Lock()
-{
- DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
-
- bool locked = false;
- if( mFileDescriptor > 0 )
- {
- if( lockf( mFileDescriptor, F_LOCK, 0 ) == 0 ) // Note, operation may block.
- {
- locked = true;
- }
- else
- {
- if( errno == EBADF )
- {
- // file descriptor is no longer valid or not writable
- mFileDescriptor = 0;
- mErrorThrown = true;
- DALI_LOG_ERROR( "### Cannot lock indicator: bad file descriptor for %s ###\n", mFilename.c_str() );
- }
- }
- }
-
- return locked;
-}
-
-void Indicator::LockFile::Unlock()
-{
- DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
- if( lockf( mFileDescriptor, F_ULOCK, 0 ) != 0 )
- {
- if( errno == EBADF )
- {
- // file descriptor is no longer valid or not writable
- mFileDescriptor = 0;
- mErrorThrown = true;
- DALI_LOG_ERROR( "### Cannot unlock indicator: bad file descriptor for %s\n", mFilename.c_str() );
- }
- }
-}
-
-bool Indicator::LockFile::RetrieveAndClearErrorStatus()
-{
- bool error = mErrorThrown;
- mErrorThrown = false;
- return error;
-}
-
-Indicator::ScopedLock::ScopedLock(LockFile* lockFile)
-: mLockFile(lockFile),
- mLocked(false)
-{
- if(mLockFile)
- {
- mLocked = mLockFile->Lock();
- }
-}
-
-Indicator::ScopedLock::~ScopedLock()
-{
- if( mLockFile )
- {
- mLockFile->Unlock();
- }
-}
-
-bool Indicator::ScopedLock::IsLocked()
-{
- return mLocked;
-}
-
-Indicator::Indicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientation, Dali::Window::IndicatorStyle style, Observer* observer )
-: mPixmap( 0 ),
- mGestureDetected( false ),
- mConnection( this ),
- mStyle( style ),
- mOpacityMode( Dali::Window::OPAQUE ),
- mState( DISCONNECTED ),
- mAdaptor(adaptor),
- mServerConnection( NULL ),
- mLock( NULL ),
- mSharedFile( NULL ),
- mObserver( observer ),
- mOrientation( orientation ),
- mRotation( 0 ),
- mImageWidth( 0 ),
- mImageHeight( 0 ),
- mVisible( Dali::Window::VISIBLE ),
- mIsShowing( true ),
- mIsAnimationPlaying( false )
-{
- mIndicatorImageActor = Dali::ImageActor::New();
- mIndicatorImageActor.SetBlendFunc( Dali::BlendingFactor::ONE, Dali::BlendingFactor::ONE_MINUS_SRC_ALPHA,
- Dali::BlendingFactor::ONE, Dali::BlendingFactor::ONE );
-
- mIndicatorImageActor.SetParentOrigin( ParentOrigin::TOP_CENTER );
- mIndicatorImageActor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
-
- // Indicator image handles the touch event including "leave"
- mIndicatorImageActor.SetLeaveRequired( true );
- mIndicatorImageActor.TouchedSignal().Connect( this, &Indicator::OnTouched );
-
- SetBackground();
- mBackgroundActor.SetParentOrigin( ParentOrigin::TOP_CENTER );
- mBackgroundActor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- mBackgroundActor.SetZ( -0.02f );
-
- // add background to image actor to move it with indicator image
- mIndicatorImageActor.Add( mBackgroundActor );
-
- mIndicatorActor = Dali::Actor::New();
- mIndicatorActor.Add( mIndicatorImageActor );
-
- if( mOrientation == Dali::Window::LANDSCAPE || mOrientation == Dali::Window::LANDSCAPE_INVERSE )
- {
- mBackgroundActor.SetVisible( false );
- }
-
- // Event handler to find out flick down gesture
- mEventActor = Dali::Actor::New();
- mEventActor.SetParentOrigin( ParentOrigin::TOP_CENTER );
- mEventActor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- mEventActor.SetZ( -0.01f );
- mIndicatorActor.Add( mEventActor );
-
- // Attach pan gesture to find flick down during hiding.
- // It can prevent the problem that scrollview gets pan gesture even indicator area is touched,
- // since it consumes the pan gesture in advance.
- mPanDetector = Dali::PanGestureDetector::New();
- mPanDetector.DetectedSignal().Connect( this, &Indicator::OnPan );
- mPanDetector.Attach( mEventActor );
-
- Open( orientation );
-
- // register indicator to accessibility manager
- Dali::AccessibilityManager accessibilityManager = AccessibilityManager::Get();
- if(accessibilityManager)
- {
- AccessibilityManager::GetImplementation( accessibilityManager ).SetIndicator( this );
- }
-}
-
-Indicator::~Indicator()
-{
- if(mEventActor)
- {
- mEventActor.TouchedSignal().Disconnect( this, &Indicator::OnTouched );
- }
- Disconnect();
-}
-
-void Indicator::SetAdaptor(Adaptor* adaptor)
-{
- mAdaptor = adaptor;
- mIndicatorBuffer->SetAdaptor( adaptor );
-}
-
-Dali::Actor Indicator::GetActor()
-{
- return mIndicatorActor;
-}
-
-void Indicator::Open( Dali::Window::WindowOrientation orientation )
-{
- DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
-
- // Calls from Window should be set up to ensure we are in a
- // disconnected state before opening a second time.
- DALI_ASSERT_DEBUG( mState == DISCONNECTED );
-
- Connect( orientation );
-
- // Change background visibility depending on orientation
- if(mOrientation == Dali::Window::PORTRAIT || mOrientation == Dali::Window::PORTRAIT_INVERSE)
- {
- mBackgroundActor.SetVisible(true);
- }
- else
- {
- mBackgroundActor.SetVisible(false);
- }
-}
-
-void Indicator::Close()
-{
- DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "State: %s\n", STATE_DEBUG_STRING(mState) );
-
- if( mState == CONNECTED )
- {
- Disconnect();
- if( mObserver != NULL )
- {
- mObserver->IndicatorClosed( this );
- }
- }
-
- Dali::Image emptyImage;
- mIndicatorImageActor.SetImage(emptyImage);
-}
-
-void Indicator::SetOpacityMode( Dali::Window::IndicatorBgOpacity mode )
-{
- mOpacityMode = mode;
- SetBackground();
-}
-
-void Indicator::SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool forceUpdate )
-{
- if ( visibleMode != mVisible || forceUpdate )
- {
- // If we were previously hidden, then we should update the image data before we display the indicator
- if ( mVisible == Dali::Window::INVISIBLE )
- {
- UpdateImageData();
- }
-
- mVisible = visibleMode;
-
- if( mIndicatorImageActor.GetImage() )
- {
- if( CheckVisibleState() && mVisible == Dali::Window::AUTO )
- {
- // hide indicator
- ShowIndicator( AUTO_INDICATOR_STAY_DURATION /* stay n sec */ );
- }
- else if( CheckVisibleState() && mVisible == Dali::Window::VISIBLE )
- {
- // show indicator
- ShowIndicator( KEEP_SHOWING );
- }
- else
- {
- // hide indicator
- ShowIndicator( HIDE_NOW );
- }
- }
- }
-}
-
-bool Indicator::IsConnected()
-{
- return ( mState == CONNECTED );
-}
-
-bool Indicator::SendMessage( int messageDomain, int messageId, const void *data, int size )
-{
- if(IsConnected())
- {
- return mServerConnection->SendEvent( OP_MSG, messageDomain, messageId, data, size );
- }
- else
- {
- return false;
- }
-}
-
-bool Indicator::OnTouched(Dali::Actor indicator, const Dali::TouchEvent& touchEvent)
-{
- if( mServerConnection )
- {
- const TouchPoint& touchPoint = touchEvent.GetPoint( 0 );
-
- // Send touch event to indicator server when indicator is showing
- if( CheckVisibleState() || mIsShowing )
- {
- switch( touchPoint.state )
- {
- case Dali::TouchPoint::Down:
- {
- IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time );
- IpcDataEvMouseDown ipcDown( touchEvent.time );
- mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) );
- mServerConnection->SendEvent( OP_EV_MOUSE_DOWN, &ipcDown, sizeof(ipcDown) );
-
- if( mVisible == Dali::Window::AUTO )
- {
- // Stop hiding indicator
- ShowIndicator( KEEP_SHOWING );
- }
- }
- break;
-
- case Dali::TouchPoint::Motion:
- {
- IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time );
- mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) );
- }
- break;
-
- case Dali::TouchPoint::Up:
- {
- IpcDataEvMouseUp ipcUp( touchEvent.time );
- mServerConnection->SendEvent( OP_EV_MOUSE_UP, &ipcUp, sizeof(ipcUp) );
-
- if( mVisible == Dali::Window::AUTO )
- {
- // Hide indicator
- ShowIndicator( 0.5f /* hide after 0.5 sec */ );
- }
- }
- break;
-
- case Dali::TouchPoint::Leave:
- {
- IpcDataEvMouseMove ipcMove( touchPoint, touchEvent.time );
- mServerConnection->SendEvent( OP_EV_MOUSE_MOVE, &ipcMove, sizeof(ipcMove) );
- IpcDataEvMouseUp ipcOut( touchEvent.time );
- mServerConnection->SendEvent( OP_EV_MOUSE_OUT, &ipcOut, sizeof(ipcOut) );
- }
- break;
-
- default:
- break;
- }
-
- return true;
- }
- }
-
- return false;
-}
-
-/**
- * Return the current orientation in degrees
- * @return value of 0, 90, 180 or 270
- */
-int Indicator::OrientationToDegrees( Dali::Window::WindowOrientation orientation )
-{
- int degree = 0;
-
- switch( orientation )
- {
- case Dali::Window::PORTRAIT:
- degree = 0;
- break;
- case Dali::Window::PORTRAIT_INVERSE:
- degree = 180;
- break;
- case Dali::Window::LANDSCAPE:
- degree = 90;
- break;
- case Dali::Window::LANDSCAPE_INVERSE:
- degree = 270;
- break;
- }
- return degree;
-}
-
-bool Indicator::Connect( Dali::Window::WindowOrientation orientation )
-{
- DALI_ASSERT_DEBUG( mState == DISCONNECTED );
-
- bool connected = false;
- mOrientation = orientation;
- mRotation = OrientationToDegrees(mOrientation);
-
- switch( orientation )
- {
- case Dali::Window::PORTRAIT:
- if(mStyle == Dali::Window::FIXED_COLOR)
- {
- connected = Connect( ELM_INDICATOR_PORTRAIT_FIXED_COLOR_STYLE );
- }
- else
- {
- connected = Connect( ELM_INDICATOR_PORTRAIT );
- }
- break;
- case Dali::Window::PORTRAIT_INVERSE:
- if(mStyle == Dali::Window::FIXED_COLOR)
- {
- connected = Connect( ELM_INDICATOR_PORTRAIT_FIXED_COLOR_STYLE );
- }
- else
- {
- connected = Connect( ELM_INDICATOR_PORTRAIT );
- }
- break;
- case Dali::Window::LANDSCAPE:
- if(mStyle == Dali::Window::FIXED_COLOR)
- {
- connected = Connect( ELM_INDICATOR_LANDSCAPE_FIXED_COLOR_STYLE );
- }
- else
- {
- connected = Connect( ELM_INDICATOR_LANDSCAPE );
- }
- break;
- case Dali::Window::LANDSCAPE_INVERSE:
- if(mStyle == Dali::Window::FIXED_COLOR)
- {
- connected = Connect( ELM_INDICATOR_LANDSCAPE_FIXED_COLOR_STYLE );
- }
- else
- {
- connected = Connect( ELM_INDICATOR_LANDSCAPE );
- }
- break;
- }
-
- return connected;
-}
-
-bool Indicator::Connect( const char *serviceName )
-{
- DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
-
- bool connected = false;
-
- mServerConnection = new ServerConnection( serviceName, 0, false, this );
- if( mServerConnection )
- {
- connected = mServerConnection->IsConnected();
- if( ! connected )
- {
- delete mServerConnection;
- mServerConnection = NULL;
- }
- }
-
- if( !connected )
- {
- StartReconnectionTimer();
- }
- else
- {
- mState = CONNECTED;
- }
-
- return connected;
-}
-
-void Indicator::StartReconnectionTimer()
-{
- if( ! mReconnectTimer )
- {
- mReconnectTimer = Dali::Timer::New(1000);
- mConnection.DisconnectAll();
- mReconnectTimer.TickSignal().Connect( mConnection, &Indicator::OnReconnectTimer );
- }
- mReconnectTimer.Start();
-}
-
-bool Indicator::OnReconnectTimer()
-{
- bool retry = false;
-
- if( mState == DISCONNECTED )
- {
- if( ! Connect( mOrientation ) )
- {
- retry = true;
- }
- }
-
- return retry;
-}
-
-void Indicator::Disconnect()
-{
- DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
-
- mState = DISCONNECTED;
-
- delete mLock;
- mLock = NULL;
-
- delete mSharedFile;
- mSharedFile = NULL;
-
- delete mServerConnection;
- mServerConnection = NULL;
-}
-
-void Indicator::NewLockFile( Ecore_Ipc_Event_Server_Data *epcEvent )
-{
- DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
-
- delete mLock;
- mLock = NULL;
-
- if ( (epcEvent->data) &&
- (epcEvent->size > 0) &&
- (((unsigned char *)epcEvent->data)[epcEvent->size - 1] == 0) )
- {
- const char* lockFile = static_cast< const char* >( epcEvent->data );
- mLock = new Indicator::LockFile( lockFile );
- if( mLock->RetrieveAndClearErrorStatus() )
- {
- DALI_LOG_ERROR( "### Indicator error: Cannot open lock file %s ###\n", lockFile );
- }
- }
-}
-
-void Indicator::Resize( int width, int height )
-{
- if( width < 1 )
- {
- width = 1;
- }
- if( height < 1 )
- {
- height = 1;
- }
-
- if( mImageWidth != width || mImageHeight != height )
- {
- mImageWidth = width;
- mImageHeight = height;
-
- // We don't currently handle the pixel buffer size being changed. Create a new image instead
- if( mSharedFile )
- {
- CreateNewImage();
- }
- }
-}
-
-void Indicator::LoadPixmapImage( Ecore_Ipc_Event_Server_Data *epcEvent )
-{
- DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
-
- // epcEvent->ref == w
- // epcEvent->ref_to == h
- // epcEvent->response == alpha
- // epcEvent->data = pixmap id
- if( ( epcEvent->data ) &&
- (epcEvent->size >= (int)sizeof(PixmapId)) )
- {
- if( mSharedFile != NULL )
- {
- delete mSharedFile;
- mSharedFile = NULL;
- }
-
- if( (epcEvent->ref > 0) && (epcEvent->ref_to > 0) )
- {
- mImageWidth = epcEvent->ref;
- mImageHeight = epcEvent->ref_to;
-
- mPixmap = *(static_cast<PixmapId*>(epcEvent->data));
- CreateNewPixmapImage();
-
- if( CheckVisibleState() )
- {
- // set default indicator type (enable the quick panel)
- OnIndicatorTypeChanged( INDICATOR_TYPE_1 );
- }
- else
- {
- // set default indicator type (disable the quick panel)
- OnIndicatorTypeChanged( INDICATOR_TYPE_2 );
- }
-
- SetVisible(mVisible, true);
- }
- }
-}
-
-void Indicator::LoadSharedImage( Ecore_Ipc_Event_Server_Data *epcEvent )
-{
- DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
-
- // epcEvent->ref == w
- // epcEvent->ref_to == h
- // epcEvent->response == alpha
- // epcEvent->data = shm ref string + nul byte
- if( ( epcEvent->data ) &&
- ( ( unsigned char * ) epcEvent->data)[ epcEvent->size - 1 ] == 0 )
- {
- if( mSharedFile != NULL )
- {
- delete mSharedFile;
- mSharedFile = NULL;
- }
-
- if( (epcEvent->ref > 0) && (epcEvent->ref_to > 0) )
- {
- mImageWidth = epcEvent->ref;
- mImageHeight = epcEvent->ref_to;
-
- char* sharedFilename = static_cast<char*>(epcEvent->data);
-
- mSharedFile = SharedFile::New( sharedFilename, mImageWidth * mImageWidth * 4, true );
- if( mSharedFile != NULL )
- {
- CreateNewImage();
- mEventActor.SetSize(mImageWidth, mImageHeight);
-
- if( CheckVisibleState() )
- {
- // set default indicator type (enable the quick panel)
- OnIndicatorTypeChanged( INDICATOR_TYPE_1 );
- }
- else
- {
- // set default indicator type (disable the quick panel)
- OnIndicatorTypeChanged( INDICATOR_TYPE_2 );
- }
-
- SetVisible(mVisible, true);
- }
- }
- }
-}
-
-void Indicator::UpdateImageData()
-{
- DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "State: %s mVisible: %s\n", STATE_DEBUG_STRING(mState), mVisible?"T":"F" );
-
- if( mState == CONNECTED && mVisible )
- {
- if(mPixmap == 0)
- {
- // in case of shm indicator (not pixmap), not sure we can skip it when mIsShowing is false
- CopyToBuffer();
- }
- else
- {
- if(mIsShowing)
- {
- mAdaptor->RequestUpdateOnce();
- }
- }
- }
-}
-
-bool Indicator::CopyToBuffer()
-{
- bool success = false;
-
- if( mLock )
- {
- Indicator::ScopedLock scopedLock(mLock);
- if( mLock->RetrieveAndClearErrorStatus() )
- {
- // Do nothing here.
- }
- else if( scopedLock.IsLocked() )
- {
- unsigned char *src = mSharedFile->GetAddress();
- size_t size = mImageWidth * mImageHeight * 4;
-
- if( mIndicatorBuffer->UpdatePixels( src, size ) )
- {
- mAdaptor->RequestUpdateOnce();
- success = true;
- }
- }
- }
-
- return success;
-}
-
-void Indicator::SetBackground()
-{
- if( ! mBackgroundActor )
- {
- ConstructBackgroundMesh();
- }
-
- switch( mOpacityMode )
- {
- case Dali::Window::TRANSLUCENT:
- {
- SetMeshDataColors( mBackgroundMesh, GRADIENT_COLORS );
- }
- break;
-
- case Dali::Window::TRANSPARENT:
- {
- SetMeshDataColors( mBackgroundMesh, Color::TRANSPARENT );
- }
- break;
-
- case Dali::Window::OPAQUE:
- default :
- {
- SetMeshDataColors( mBackgroundMesh, Color::BLACK );
- }
- break;
- }
-}
-
-void Indicator::CreateNewPixmapImage()
-{
- DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "W:%d H:%d\n", mImageWidth, mImageHeight );
- Dali::PixmapImagePtr pixmapImage = Dali::PixmapImage::New(mPixmap, Dali::Adaptor::Get());
-
- if( pixmapImage )
- {
- mIndicatorImageActor.SetImage( Dali::Image::New(*pixmapImage) );
- mIndicatorImageActor.SetSize( mImageWidth, mImageHeight );
- mIndicatorActor.SetSize( mImageWidth, mImageHeight );
- mEventActor.SetSize(mImageWidth, mImageHeight);
-
- SetBackground();
- if( mBackgroundActor )
- {
- mBackgroundActor.SetSize( mImageWidth, mImageHeight );
- }
- }
- else
- {
- DALI_LOG_WARNING("### Cannot create indicator image - disconnecting ###\n");
- Disconnect();
- if( mObserver != NULL )
- {
- mObserver->IndicatorClosed( this );
- }
- // Don't do connection in this callback - strange things happen!
- StartReconnectionTimer();
- }
-}
-
-void Indicator::CreateNewImage()
-{
- DALI_LOG_TRACE_METHOD_FMT( gIndicatorLogFilter, "W:%d H:%d\n", mImageWidth, mImageHeight );
- mIndicatorBuffer = new IndicatorBuffer( mAdaptor, mImageWidth, mImageHeight, Pixel::BGRA8888 );
- Dali::Image image = Dali::Image::New( mIndicatorBuffer->GetNativeImage() );
-
- if( CopyToBuffer() ) // Only create images if we have valid image buffer
- {
- mIndicatorImageActor.SetImage( image );
- mIndicatorImageActor.SetSize( mImageWidth, mImageHeight );
- mIndicatorActor.SetSize( mImageWidth, mImageHeight );
- mEventActor.SetSize(mImageWidth, mImageHeight);
-
- SetBackground();
- if( mBackgroundActor )
- {
- mBackgroundActor.SetSize( mImageWidth, mImageHeight );
- }
- }
- else
- {
- DALI_LOG_WARNING("### Cannot create indicator image - disconnecting ###\n");
- Disconnect();
- if( mObserver != NULL )
- {
- mObserver->IndicatorClosed( this );
- }
- // Don't do connection in this callback - strange things happen!
- StartReconnectionTimer();
- }
-}
-
-void Indicator::OnIndicatorTypeChanged( Type indicatorType )
-{
- if( mObserver != NULL )
- {
- mObserver->IndicatorTypeChanged( indicatorType );
- }
-}
-
-void Indicator::DataReceived( void* event )
-{
- DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
- Ecore_Ipc_Event_Server_Data *epcEvent = static_cast<Ecore_Ipc_Event_Server_Data *>( event );
-
- switch( epcEvent->minor )
- {
- case OP_UPDATE:
- DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_UPDATE\n" );
- if(mPixmap != 0 && mIsShowing)
- {
- mAdaptor->RequestUpdateOnce();
- }
- break;
-
- case OP_UPDATE_DONE:
- DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_UPDATE_DONE\n" );
- UpdateImageData();
- break;
-
- case OP_LOCK_FILE:
- DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_LOCK_FILE\n" );
- NewLockFile( epcEvent );
- break;
-
- case OP_SHM_REF:
- DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_SHM_REF\n" );
- LoadSharedImage( epcEvent );
- break;
-
- case OP_PIXMAP_REF:
- DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_PIXMAP_REF\n" );
- LoadPixmapImage( epcEvent );
- break;
-
- case OP_RESIZE:
- DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_RESIZE\n" );
-
- if( (epcEvent->data) && (epcEvent->size >= (int)sizeof(IpcDataResize)) )
- {
- IpcDataResize *newSize = static_cast<IpcDataResize*>( epcEvent->data );
- Resize( newSize->w, newSize->h );
- }
- break;
-
- case OP_MSG_PARENT:
- {
- int msgDomain = epcEvent->ref;
- int msgId = epcEvent->ref_to;
-
- void *msgData = NULL;
- int msgDataSize = 0;
- msgData = epcEvent->data;
- msgDataSize = epcEvent->size;
-
- if( msgDomain == MSG_DOMAIN_CONTROL_INDICATOR )
- {
- switch( msgId )
- {
- case MSG_ID_INDICATOR_TYPE:
- {
- DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "Indicator client received: OP_MSG_PARENT, INDICATOR_TYPE\n" );
- Type* indicatorType = static_cast<Type*>( epcEvent->data );
- OnIndicatorTypeChanged( *indicatorType );
- break;
- }
-
- case MSG_ID_INDICATOR_START_ANIMATION:
- {
- if (msgDataSize != (int)sizeof(IpcIndicatorDataAnimation))
- {
- DALI_LOG_ERROR("Message data is incorrect");
- break;
- }
-
- IpcIndicatorDataAnimation *animData = static_cast<IpcIndicatorDataAnimation*>(msgData);
-
- if(!CheckVisibleState())
- {
- ShowIndicator( animData->duration /* n sec */ );
- }
- break;
- }
-
- }
- }
- break;
- }
- }
-}
-
-void Indicator::ConnectionClosed()
-{
- DALI_LOG_TRACE_METHOD( gIndicatorLogFilter );
-
- // Will get this callback if the server connection failed to start up.
- delete mServerConnection;
- mServerConnection = NULL;
- mState = DISCONNECTED;
-
- // Attempt to re-connect
- Connect(mOrientation);
-}
-
-bool Indicator::CheckVisibleState()
-{
- if( mOrientation == Dali::Window::LANDSCAPE
- || mOrientation == Dali::Window::LANDSCAPE_INVERSE
- || (mVisible != Dali::Window::VISIBLE) )
- {
- return false;
- }
-
- return true;
-}
-
-void Indicator::ConstructBackgroundMesh()
-{
- // Construct 5 interval mesh
- // 0 +---+ 1
- // | \ |
- // 2 +---+ 3
- // | \ |
- // 4 +---+ 5
- // | \ |
- // 6 +---+ 7
- // | \ |
- // 8 +---+ 9
- // | \ |
- // 10 +---+ 11
- Dali::AnimatableMesh::Faces faces;
- faces.reserve(NUM_GRADIENT_INTERVALS * 6); // 2 tris per interval
- for(int i=0; i<NUM_GRADIENT_INTERVALS; i++)
- {
- int j=i*2;
- faces.push_back(j); faces.push_back(j+3); faces.push_back(j+1);
- faces.push_back(j); faces.push_back(j+2); faces.push_back(j+3);
- }
-
- mBackgroundMesh = Dali::AnimatableMesh::New((NUM_GRADIENT_INTERVALS+1)*2, faces);
- float interval=1.0f / (float)NUM_GRADIENT_INTERVALS;
- for(int i=0;i<NUM_GRADIENT_INTERVALS+1;i++)
- {
- int j=i*2;
- mBackgroundMesh[j ].SetPosition(Vector3(-0.5f, -0.5f+(interval*(float)i), 0.0f));
- mBackgroundMesh[j+1].SetPosition(Vector3( 0.5f, -0.5f+(interval*(float)i), 0.0f));
- }
-
- mBackgroundActor = Dali::MeshActor::New(mBackgroundMesh);
- mBackgroundActor.SetAffectedByLighting(false);
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( MESH_VERTEX_SHADER, MESH_FRAGMENT_SHADER,
- GEOMETRY_TYPE_MESH, // Using vertex color
- Dali::ShaderEffect::HINT_BLENDING );
- mBackgroundActor.SetShaderEffect(shaderEffect);
-}
-
-/**
- * duration can be this
- *
- * enum
- * {
- * KEEP_SHOWING = -1,
- * HIDE_NOW = 0
- * };
- */
-void Indicator::ShowIndicator(float duration)
-{
- if( !mIndicatorAnimation )
- {
- mIndicatorAnimation = Dali::Animation::New(SLIDING_ANIMATION_DURATION);
- mIndicatorAnimation.FinishedSignal().Connect(this, &Indicator::OnAnimationFinished);
- }
-
- if(mIsShowing && duration != 0)
- {
- // If need to show during showing, do nothing.
- // In 2nd phase (below) will update timer
- }
- else if(!mIsShowing && mIsAnimationPlaying && duration == 0)
- {
- // If need to hide during hiding or hidden already, do nothing
- }
- else
- {
- if(duration == 0)
- {
- mIndicatorAnimation.MoveTo(mIndicatorImageActor, Vector3(0, -mImageHeight, 0), Dali::AlphaFunctions::EaseOut);
-
- mIsShowing = false;
-
- OnIndicatorTypeChanged( INDICATOR_TYPE_2 ); // un-toucable
- }
- else
- {
- mIndicatorAnimation.MoveTo(mIndicatorImageActor, Vector3(0, 0, 0), Dali::AlphaFunctions::EaseOut);
-
- mIsShowing = true;
-
- OnIndicatorTypeChanged( INDICATOR_TYPE_1 ); // touchable
- }
-
- mIndicatorAnimation.Play();
- mIsAnimationPlaying = true;
- }
-
- if(duration > 0)
- {
- if(!mShowTimer)
- {
- mShowTimer = Dali::Timer::New(1000 * duration);
- mShowTimer.TickSignal().Connect(this, &Indicator::OnShowTimer);
- }
- mShowTimer.SetInterval(1000* duration);
- mShowTimer.Start();
-
- if( mVisible == Dali::Window::AUTO )
- {
- // check the stage touch
- Dali::Stage::GetCurrent().TouchedSignal().Connect( this, &Indicator::OnStageTouched );
- }
- }
- else
- {
- if(mShowTimer && mShowTimer.IsRunning())
- {
- mShowTimer.Stop();
- }
-
- if( mVisible == Dali::Window::AUTO )
- {
- // check the stage touch
- Dali::Stage::GetCurrent().TouchedSignal().Disconnect( this, &Indicator::OnStageTouched );
- }
- }
-}
-
-bool Indicator::OnShowTimer()
-{
- // after time up, hide indicator
- ShowIndicator( HIDE_NOW );
-
- return false;
-}
-
-void Indicator::OnAnimationFinished(Dali::Animation& animation)
-{
- mIsAnimationPlaying = false;
-}
-
-void Indicator::OnPan( Dali::Actor actor, Dali::PanGesture gesture )
-{
- if( mServerConnection )
- {
- switch( gesture.state )
- {
- case Gesture::Started:
- {
- mGestureDetected = false;
-
- // The gesture position is the current position after it has moved by the displacement.
- // We want to reference the original position.
- mGestureDeltaY = gesture.position.y - gesture.displacement.y;
- }
-
- // No break, Fall through
- case Gesture::Continuing:
- {
- if( mVisible == Dali::Window::AUTO && !mIsShowing )
- {
- // Only take one touch point
- if( gesture.numberOfTouches == 1 && mGestureDetected == false )
- {
- mGestureDeltaY += gesture.displacement.y;
-
- if( mGestureDeltaY >= mImageHeight * SHOWING_DISTANCE_HEIGHT_RATE )
- {
- ShowIndicator( AUTO_INDICATOR_STAY_DURATION );
- mGestureDetected = true;
- }
- }
- }
-
- break;
- }
-
- case Gesture::Finished:
- case Gesture::Cancelled:
- {
- // if indicator is showing, hide again when touching is finished (Since touch leave is activated, checking it in gesture::finish instead of touch::up)
- if( mVisible == Dali::Window::AUTO && mIsShowing )
- {
- ShowIndicator( AUTO_INDICATOR_STAY_DURATION );
- }
- break;
- }
-
-
- default:
- break;
- }
- }
-}
-
-void Indicator::OnStageTouched(const Dali::TouchEvent& touchEvent)
-{
- const TouchPoint& touchPoint = touchEvent.GetPoint( 0 );
-
- // when stage is touched while indicator is showing temporary, hide it
- if( mIsShowing && ( CheckVisibleState() == false || mVisible == Dali::Window::AUTO ) )
- {
- switch( touchPoint.state )
- {
- case Dali::TouchPoint::Down:
- {
- ShowIndicator( HIDE_NOW );
- break;
- }
-
- default:
- break;
- }
- }
-}
-
-} // Adaptor
-} // Internal
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_INDICATOR_H__
-#define __DALI_INTERNAL_INDICATOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/images/bitmap-image.h>
-#include <dali/public-api/actors/image-actor.h>
-#include <dali/public-api/actors/mesh-actor.h>
-#include <dali/public-api/geometry/animatable-mesh.h>
-#include <dali/public-api/adaptor-framework/common/window.h>
-#include <dali/public-api/adaptor-framework/common/timer.h>
-#include <dali/public-api/animation/animation.h>
-#include <dali/public-api/events/pan-gesture.h>
-#include <dali/public-api/events/pan-gesture-detector.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/indicator-buffer.h>
-#include <internal/common/server-connection.h>
-#include <internal/common/shared-file.h>
-
-namespace Dali
-{
-namespace Integration
-{
-class Core;
-}
-
-namespace Internal
-{
-namespace Adaptor
-{
-class Adaptor;
-
-typedef unsigned int PixmapId;
-
-/**
- * The Indicator class connects to the indicator server, and gets and draws the indicator
- * for the given orientation.
- */
-class Indicator : public ConnectionTracker, public ServerConnection::Observer
-{
-public:
- enum State
- {
- DISCONNECTED,
- CONNECTED
- };
-
- enum Type
- {
- INDICATOR_TYPE_UNKNOWN,
- INDICATOR_TYPE_1,
- INDICATOR_TYPE_2
- };
-
-public:
- class Observer
- {
- public:
- /**
- * Notify the observer if the indicator type changes
- * @param[in] type The new indicator type
- */
- virtual void IndicatorTypeChanged( Type type ) = 0;
-
- /**
- * Notify the observer when the upload has completed.
- * @param[in] indicator The indicator that has finished uploading.
- */
- virtual void IndicatorClosed(Indicator* indicator) = 0;
- };
-
-protected:
- /**
- * Class to encapsulate lock file
- */
- class LockFile
- {
- public:
- /**
- * Constructor. open lock file
- */
- LockFile(const char* filename);
-
- /**
- * Close lock file
- */
- ~LockFile();
-
- /**
- * Grab an exclusive lock on this file
- * @return true if the lock succeeded, false if it failed
- */
- bool Lock();
-
- /**
- * Remove the lock
- */
- void Unlock();
-
- /**
- * Test if there is an error with the lock file, and clears
- * the error flag;
- * @return true if an error was thrown
- */
- bool RetrieveAndClearErrorStatus();
-
- private:
- std::string mFilename;
- int mFileDescriptor;
- bool mErrorThrown;
- };
-
- /**
- * Class to ensure lock/unlock through object destruction
- */
- class ScopedLock
- {
- public:
- /**
- * Constructor - creates a lock on the lockfile
- * @param[in] lockFile The lockfile to use
- */
- ScopedLock( LockFile* lockFile );
-
- /**
- * Destructor - removes the lock (if any) on the lockfile
- */
- ~ScopedLock();
-
- /**
- * Method to test if the locking succeeded
- * @return TRUE if locked
- */
- bool IsLocked();
-
- private:
- LockFile* mLockFile; ///< The lock file to use
- bool mLocked; ///< Whether the lock succeeded
- };
-
-
-public:
- /**
- * Constructor. Creates a new indicator and opens a connection for
- * the required orientation.
- * @param[in] orientation The orientation in which to draw the indicator
- * @param[in] observer The indicator closed
- */
- Indicator( Adaptor* adaptor,
- Dali::Window::WindowOrientation orientation,
- Dali::Window::IndicatorStyle style,
- Observer* observer );
-
- /**
- * Destructor
- */
- virtual ~Indicator();
-
- void SetAdaptor(Adaptor* adaptor);
-
- /**
- * Get the actor which contains the indicator image. Ensure that the handle is
- * released when no longer needed.
- * Changes from the indicator service will modify the image and resize the actor appropriately.
- * @return The indicator actor.
- */
- Dali::Actor GetActor();
-
- /**
- * Opens a new connection for the required orientation.
- * @param[in] orientation The new orientation
- */
- void Open( Dali::Window::WindowOrientation orientation );
-
- /**
- * Close the current connection. Will respond with Observer::IndicatorClosed()
- * when done.
- * @note, IndicatorClosed() will be called synchronously if there's no update
- * in progress, or asychronously if waiting for SignalUploaded )
- */
- void Close();
-
- /**
- * Set the opacity mode of the indicator background.
- * @param[in] mode opacity mode
- */
- void SetOpacityMode( Dali::Window::IndicatorBgOpacity mode );
-
- /**
- * Set whether the indicator is visible or not.
- * @param[in] visibleMode visible mode for indicator bar.
- * @param[in] forceUpdate true if want to change visible mode forcely
- */
- void SetVisible( Dali::Window::IndicatorVisibleMode visibleMode, bool forceUpdate = false );
-
- /**
- * Check whether the indicator is connected to the indicator service.
- * @return whether the indicator is connected or not.
- */
- bool IsConnected();
-
- /**
- * Send message to the indicator service.
- * @param[in] messageDomain Message Reference number
- * @param[in] messageId Reference number of the message this message refers to
- * @param[in] data The data to send as part of the message
- * @param[in] size Length of the data, in bytes, to send
- * @return whether the message is sent successfully or not
- */
- bool SendMessage( int messageDomain, int messageId, const void *data, int size );
-
-private:
- /**
- * Initialize the indicator actors
- */
- void Initialize();
-
- /**
- * Set the opacity of the background image
- */
- void SetBackgroundOpacity( Dali::Window::IndicatorBgOpacity opacity );
-
- /**
- * Touch event callback.
- * It should pass the valid touch event to indicator server
- *
- * @param[in] indicator The indicator actor that was touched
- * @param[in] touchEvent The touch event
- */
- bool OnTouched(Dali::Actor indicator, const TouchEvent& touchEvent);
-
- /**
- * Pan gesture callback.
- * It finds flick down gesture to show hidden indicator image
- *
- * @param[in] actor The actor for gesture
- * @param[in] gesture The gesture event
- */
- void OnPan( Dali::Actor actor, Dali::PanGesture gesture );
-
- /**
- * Touch event callback on stage.
- * If stage is touched, hide showing indicator image
- *
- * @param[in] touchEvent The touch event
- */
- void OnStageTouched(const Dali::TouchEvent& touchEvent);
-
- /**
- * Return the given orientation in degrees
- *
- * @param[in] orientation The given indicator orientation
- * @return value of 0, 90, 180 or 270
- */
- int OrientationToDegrees( Dali::Window::WindowOrientation orientation );
-
- /**
- * Connect to the indicator service matching the orientation
- * @param[in] orientation The current indicator orientation
- */
- bool Connect( Dali::Window::WindowOrientation orientation );
-
- /**
- * Connect to the indicator service
- * @param[in] serviceName The indicator service name
- */
- bool Connect( const char *serviceName );
-
- /**
- * Start the reconnection timer. This will run every second until we reconnect to
- * the indicator service.
- */
- void StartReconnectionTimer();
-
- /**
- * If connection failed, attempt to re-connect every second
- */
- bool OnReconnectTimer();
-
- /**
- * Disconnect from the indicator service
- */
- void Disconnect();
-
- /**
- * Close existing lock file and open the new lock file.
- * @param[in] epcEvent Current ecore event.
- */
- void NewLockFile(Ecore_Ipc_Event_Server_Data *epcEvent);
-
- /**
- * Handle Resize event
- * @param[in] width The new width
- * @param[in] height The new height
- */
- void Resize(int width, int height);
-
- /**
- * Load the shared indicator image
- * @param[in] epcEvent The event containing the image data
- */
- void LoadSharedImage(Ecore_Ipc_Event_Server_Data *epcEvent);
-
- /**
- * Load the pixmap indicator image
- * @param[in] epcEvent The event containing the image data
- */
- void LoadPixmapImage( Ecore_Ipc_Event_Server_Data *epcEvent );
-
- /**
- * Inform dali that the indicator data has been updated.
- */
- void UpdateImageData();
-
- /**
- * Lock the temporary file, Copy the shared image into IndicatorBuffer
- * and then unlock the temporary file.
- * Caller should ensure we are not writing image to gl texture.
- */
- bool CopyToBuffer();
-
- /**
- * Update the background with the correct colors
- */
- void SetBackground();
-
- /**
- * Create a new image for the indicator, and set up signal handling for it.
- */
- void CreateNewImage();
-
- /**
- * Create a new pixmap image for the indicator, and set up signal handling for it.
- */
- void CreateNewPixmapImage();
-
- /**
- * Indicator type has changed.
- * Inform observer
- * @param[in] type The new indicator type
- */
- void OnIndicatorTypeChanged( Type type );
-
- /**
- * Check whether the indicator could be visible or invisible
- * @return true if indicator should be shown
- */
- bool CheckVisibleState();
-
- /**
- * Show/Hide indicator actor with effect
- * @param[in] duration how long need to show the indicator,
- * if it equal to 0, hide the indicator
- * if it less than 0, show always
- */
- void ShowIndicator(float duration);
-
- /**
- * Showing timer callback
- */
- bool OnShowTimer();
-
- /**
- * Showing animation finished callback
- * @param[in] animation
- */
- void OnAnimationFinished(Dali::Animation& animation);
-
-private: // Implementation of ServerConnection::Observer
- /**
- * @copydoc Dali::Internal::Adaptor::ServerConnection::Observer::DataReceived()
- */
- virtual void DataReceived(void* event);
-
- /**
- * @copydoc Dali::Internal::Adaptor::ServerConnection::Observer::DataReceived()
- */
- virtual void ConnectionClosed();
-
-private:
- /**
- * Construct the gradient mesh
- */
- void ConstructBackgroundMesh();
-
-private:
-
- IndicatorBufferPtr mIndicatorBuffer; ///< class which handles indicator rendering
- PixmapId mPixmap; ///< Pixmap including indicator content
- Dali::Image mImage; ///< Image created from mIndicatorBuffer
- Dali::ImageActor mIndicatorImageActor; ///< Actor created from mImage
-
- Dali::AnimatableMesh mBackgroundMesh;
- Dali::MeshActor mBackgroundActor; ///< Actor for background
- Dali::Actor mIndicatorActor; ///< Handle to topmost indicator actor
- Dali::Actor mEventActor; ///< Handle to event
- Dali::PanGestureDetector mPanDetector; ///< Pan detector to find flick gesture for hidden indicator
- float mGestureDeltaY; ///< Checking how much panning moved
- bool mGestureDetected; ///< Whether find the flick gesture
-
- Dali::Timer mReconnectTimer; ///< Reconnection timer
- SlotDelegate< Indicator > mConnection;
-
- Dali::Window::IndicatorStyle mStyle; ///< Style of the indicator
- Dali::Window::IndicatorBgOpacity mOpacityMode; ///< Opacity enum for background
- Indicator::State mState; ///< The connection state
-
- Adaptor* mAdaptor;
- ServerConnection* mServerConnection;
- LockFile* mLock; ///< File lock for the shared file
- SharedFile* mSharedFile; ///< Shared file
- Indicator::Observer* mObserver; ///< Upload observer
-
- Dali::Window::WindowOrientation mOrientation;
- int mRotation; ///< Orientation in degrees
- int mImageWidth;
- int mImageHeight;
- Dali::Window::IndicatorVisibleMode mVisible; ///< Whether the indicator is visible
-
- Dali::Timer mShowTimer; ///< Timer to show indicator
- bool mIsShowing; ///< Whether the indicator is showing on the screen
- Dali::Animation mIndicatorAnimation; ///< Animation to show/hide indicator image
-
- bool mIsAnimationPlaying; ///< Whether the animation is playing
-};
-
-} // Adaptor
-} // Internal
-} // Dali
-
-#endif
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "kernel-trace.h"
-
-// INTERNAL HEADERS
-#include <dali/integration-api/debug.h>
-
-// EXTERNAL HEADERS
-#include <fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-const char* TRACE_MARKER_FILE = "/sys/kernel/debug/tracing/trace_marker";
-const char* SPI_PREFIX = "SPI_EV_DALI_"; ///< prefix to let the SPI tool know it should read the trace
-}// un-named name space
-
-KernelTrace::KernelTrace()
-: mFileDescriptor( 0 ),
- mLoggedError( false )
-{
-}
-
-KernelTrace::~KernelTrace()
-{
- if( mFileDescriptor )
- {
- close( mFileDescriptor );
- }
-}
-
-// If this function doesn't appear to work, you can test manually on the device.
-// $ cd /sys/kernel/debug/tracing
-//
-// If the folder doesn't exist then the kernel needs to be re-built with ftrace enabled
-// If it does exist, then you can continue to test ftrace is working:
-//
-// $ echo 1 > tracing_enabled
-// $ echo "test" > trace_marker
-// $ cat trace
-// should print out test message
-// If the message did not get added to the trace, then check you have write permissions to the trace_marker file.
-//
-//
-void KernelTrace::Trace( const std::string& traceMessage )
-{
- // Open the trace_marker file
- if( mFileDescriptor == 0 )
- {
- mFileDescriptor = open( TRACE_MARKER_FILE , O_WRONLY);
- if( mFileDescriptor == -1 )
- {
- // we want to keep trying to open it, so it will start working if someone fixes
- // the permissions on the trace marker
- mFileDescriptor = 0;
-
- // first time we fail to open the file, log an error
- if( !mLoggedError )
- {
- mLoggedError = true;
- DALI_LOG_ERROR("Failed to open /sys/kernel/debug/tracing/trace_marker for writing please check file permissions.");
- }
-
- }
- }
-
- if( mFileDescriptor > 0 )
- {
- std::string msg( SPI_PREFIX );
- msg+=traceMessage;
-
- int ret = write( mFileDescriptor, msg.c_str(), msg.length() );
- // if it failed then close the file description and try again next time we trace
- if( ret < 0 )
- {
- close( mFileDescriptor );
- mFileDescriptor = 0;
- }
- }
-}
-
-} // namespace Internal
-
-} // namespace Adaptor
-
-} // namespace Dali
-
+++ /dev/null
-#ifndef __DALI_INTERNAL_ADAPTOR_KERNEL_TRACE_H__
-#define __DALI_INTERNAL_ADAPTOR_KERNEL_TRACE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <base/interfaces/kernel-trace-interface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Concrete Kernel Tracing Interface.
- * Used to log trace messages to the kernel using ftrace.
- *
- */
-class KernelTrace : public KernelTraceInterface
-{
-public:
-
- /**
- * Constructor
- */
- KernelTrace();
-
- /**
- * Destructor
- */
- virtual ~KernelTrace();
-
- /**
- * @copydoc KernelTracerInterface::KernelTrace()
- */
- virtual void Trace( const std::string& traceMessage );
-
-private:
-
- int mFileDescriptor;
- bool mLoggedError:1;
-
-};
-
-} // namespace Internal
-
-} // namespace Adaptor
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ADAPTOR_KERNEL_TRACE_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "key-impl.h"
-
-// EXTERNAL INCLUDES
-#include <utilX.h>
-#include <map>
-#include <string.h>
-#include <iostream>
-
-
-#include <dali/integration-api/debug.h>
-
-
-namespace Dali
-{
-
-const KEY DALI_KEY_INVALID = -1;
-const KEY DALI_KEY_ESCAPE = 9;
-const KEY DALI_KEY_BACK = 166;
-const KEY DALI_KEY_CAMERA = 167;
-const KEY DALI_KEY_CONFIG = 168;
-const KEY DALI_KEY_POWER = 169;
-const KEY DALI_KEY_PAUSE = 170;
-const KEY DALI_KEY_CANCEL = 171;
-const KEY DALI_KEY_PLAY_CD = 172;
-const KEY DALI_KEY_STOP_CD = 173;
-const KEY DALI_KEY_PAUSE_CD = 174;
-const KEY DALI_KEY_NEXT_SONG = 175;
-const KEY DALI_KEY_PREVIOUS_SONG = 176;
-const KEY DALI_KEY_REWIND = 177;
-const KEY DALI_KEY_FASTFORWARD = 178;
-const KEY DALI_KEY_MEDIA = 179;
-const KEY DALI_KEY_PLAY_PAUSE = 180;
-const KEY DALI_KEY_MUTE = 181;
-const KEY DALI_KEY_SEND = 182;
-const KEY DALI_KEY_SELECT = 183;
-const KEY DALI_KEY_END = DALI_KEY_BACK;
-const KEY DALI_KEY_MENU = DALI_KEY_SEND;
-const KEY DALI_KEY_HOME = DALI_KEY_SELECT;
-const KEY DALI_KEY_HOMEPAGE = 187;
-const KEY DALI_KEY_WEBPAGE = 188;
-const KEY DALI_KEY_MAIL = 189;
-const KEY DALI_KEY_SCREENSAVER = 190;
-const KEY DALI_KEY_BRIGHTNESS_UP = 191;
-const KEY DALI_KEY_BRIGHTNESS_DOWN = 192;
-const KEY DALI_KEY_SOFT_KBD = 193;
-const KEY DALI_KEY_QUICK_PANEL = 194;
-const KEY DALI_KEY_TASK_SWITCH = 195;
-const KEY DALI_KEY_APPS = 196;
-const KEY DALI_KEY_SEARCH = 197;
-const KEY DALI_KEY_VOICE = 198;
-const KEY DALI_KEY_LANGUAGE = 199;
-const KEY DALI_KEY_VOLUME_UP = 200;
-const KEY DALI_KEY_VOLUME_DOWN = 201;
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace KeyLookup
-{
-
-namespace
-{
-
-struct KeyLookup
-{
- const char* keyName; ///< X string representation
- const int daliKeyCode; ///< Dali Enum Representation
- const bool deviceButton; ///< Whether the key is from a button on the device
-};
-
-// matches a DALI_KEY enum, to a X key name
-KeyLookup KeyLookupTable[]=
-{
- // more than one key name can be assigned to a single dali-key code
- // e.g. Menu and KEY_MENU("FS86KeyMenu") are both assigned to DALI_KEY_MENU
-
- { "Escape", DALI_KEY_ESCAPE, false }, // item not defined in utilX
- { "Menu", DALI_KEY_MENU, false }, // item not defined in utilX
- { KEY_CAMERA, DALI_KEY_CAMERA, false },
- { KEY_CONFIG, DALI_KEY_CONFIG, false },
- { KEY_POWER, DALI_KEY_POWER, true },
- { KEY_PAUSE, DALI_KEY_PAUSE, false },
- { KEY_CANCEL, DALI_KEY_CANCEL, false },
- { KEY_PLAYCD, DALI_KEY_PLAY_CD, false },
- { KEY_STOPCD, DALI_KEY_STOP_CD, false },
- { KEY_PAUSECD, DALI_KEY_PAUSE_CD, false },
- { KEY_NEXTSONG, DALI_KEY_NEXT_SONG, false },
- { KEY_PREVIOUSSONG, DALI_KEY_PREVIOUS_SONG, false },
- { KEY_REWIND, DALI_KEY_REWIND, false },
- { KEY_FASTFORWARD, DALI_KEY_FASTFORWARD, false },
- { KEY_MEDIA, DALI_KEY_MEDIA, false },
- { KEY_PLAYPAUSE, DALI_KEY_PLAY_PAUSE, false },
- { KEY_MUTE, DALI_KEY_MUTE, false },
- { KEY_SEND, DALI_KEY_SEND, true },
- { KEY_SELECT, DALI_KEY_SELECT, true },
- { KEY_END, DALI_KEY_END, true },
- { KEY_MENU, DALI_KEY_MENU, true },
- { KEY_HOME, DALI_KEY_HOME, true },
- { KEY_BACK, DALI_KEY_BACK, true },
- { KEY_HOMEPAGE, DALI_KEY_HOMEPAGE, false },
- { KEY_WEBPAGE, DALI_KEY_WEBPAGE, false },
- { KEY_MAIL, DALI_KEY_MAIL, false },
- { KEY_SCREENSAVER, DALI_KEY_SCREENSAVER, false },
- { KEY_BRIGHTNESSUP, DALI_KEY_BRIGHTNESS_UP, false },
- { KEY_BRIGHTNESSDOWN, DALI_KEY_BRIGHTNESS_DOWN, false },
- { KEY_SOFTKBD, DALI_KEY_SOFT_KBD, false },
- { KEY_QUICKPANEL, DALI_KEY_QUICK_PANEL, false },
- { KEY_TASKSWITCH, DALI_KEY_TASK_SWITCH, false },
- { KEY_APPS, DALI_KEY_APPS, false },
- { KEY_SEARCH, DALI_KEY_SEARCH, false },
- { KEY_VOICE, DALI_KEY_VOICE, false },
- { KEY_LANGUAGE, DALI_KEY_LANGUAGE, false },
- { KEY_VOLUMEUP, DALI_KEY_VOLUME_UP, true },
- { KEY_VOLUMEDOWN, DALI_KEY_VOLUME_DOWN, true },
-};
-
-const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable))/ (sizeof(KeyLookup));
-
-class KeyMap
-{
- public:
-
- KeyMap():
- mLookup( cmpString )
- {
- // create the lookup
- for( size_t i = 0; i < KEY_LOOKUP_COUNT ; ++i )
- {
- const KeyLookup& keyLookup( KeyLookupTable[i] );
- mLookup[ keyLookup.keyName ] = DaliKeyType( keyLookup.daliKeyCode, keyLookup.deviceButton );
- }
- }
-
- int GetDaliKeyEnum( const char* keyName ) const
- {
- Lookup::const_iterator i = mLookup.find( keyName );
- if( i == mLookup.end() )
- {
- return -1;
- }
- else
- {
- return (*i).second.first;
- }
- }
-
- bool IsDeviceButton( const char* keyName ) const
- {
- Lookup::const_iterator i = mLookup.find( keyName );
- if ( i != mLookup.end() )
- {
- return (*i).second.second;
- }
- return false;
- }
-
- private:
-
- /**
- * compare function, to compare string by pointer
- */
- static bool cmpString( const char* a, const char* b)
- {
- return strcmp(a, b) < 0;
- }
-
- typedef std::pair< int, bool > DaliKeyType;
- typedef std::map<const char* /* key name */, DaliKeyType /* key code */, bool(*) ( char const* a, char const* b) > Lookup;
- Lookup mLookup;
-
-};
-const KeyMap globalKeyLookup;
-
-} // un-named name space
-
-bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey)
-{
- int key = globalKeyLookup.GetDaliKeyEnum( keyEvent.keyPressedName.c_str() );
- return daliKey == key;
-}
-
-bool IsDeviceButton( const char* keyName )
-{
- return globalKeyLookup.IsDeviceButton( keyName );
-}
-
-} // namespace KeyLookup
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_KEY_IMPL_H__
-#define __DALI_KEY_IMPL_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/common/key.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Implementation of the Key matching
- */
-namespace KeyLookup
-{
-
-/**
- * @copydoc Dali::IsKey()
- */
-bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey);
-
-/**
- * Check if a the given key name string is a button on the device itself.
- * @param keyName A pointer to the key name
- * @return true if the key is matched, false if not
- */
-bool IsDeviceButton( const char* keyName );
-
-} // namespace KeyLookup
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_KEY_IMPL_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "locale-utils.h"
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace Locale
-{
-
-using Dali::VirtualKeyboard::TextDirection;
-using Dali::VirtualKeyboard::LeftToRight;
-using Dali::VirtualKeyboard::RightToLeft;
-
-namespace
-{
-
-struct LocaleDirection
-{
- const char * locale;
- const char * name;
- TextDirection direction;
-};
-
-const LocaleDirection LOCALE_DIRECTION_LOOKUP_TABLE[] =
-{
- { "af", "Afrikaans", LeftToRight },
- { "am", "Amharic", LeftToRight },
- { "ar", "Arabic", RightToLeft },
- { "as", "Assamese", LeftToRight },
- { "az", "Azeri", LeftToRight },
- { "be", "Belarusian", LeftToRight },
- { "bg", "Bulgarian", LeftToRight },
- { "bn", "Bengali", LeftToRight },
- { "bo", "Tibetan", LeftToRight },
- { "bs", "Bosnian", LeftToRight },
- { "ca", "Catalan", LeftToRight },
- { "cs", "Czech", LeftToRight },
- { "cy", "Welsh", LeftToRight },
- { "da", "Danish", LeftToRight },
- { "de", "German", LeftToRight },
- { "dv", "Divehi", RightToLeft },
- { "el", "Greek", LeftToRight },
- { "en", "English", LeftToRight },
- { "es", "Spanish", LeftToRight },
- { "et", "Estonian", LeftToRight },
- { "eu", "Basque", LeftToRight },
- { "fa", "Farsi", RightToLeft },
- { "fi", "Finnish", LeftToRight },
- { "fo", "Faroese", LeftToRight },
- { "fr", "French", LeftToRight },
- { "gd", "Gaelic", LeftToRight },
- { "gl", "Galician", LeftToRight },
- { "gn", "Guarani", LeftToRight },
- { "gu", "Gujarati", LeftToRight },
- { "he", "Hebrew", RightToLeft },
- { "hi", "Hindi", LeftToRight },
- { "hr", "Croatian", LeftToRight },
- { "hu", "Hungarian", LeftToRight },
- { "hy", "Armenian", LeftToRight },
- { "id", "Indonesian", LeftToRight },
- { "is", "Icelandic", LeftToRight },
- { "it", "Italian", LeftToRight },
- { "ja", "Japanese", LeftToRight },
- { "ka", "Georgian", LeftToRight },
- { "kk", "Kazakh", RightToLeft },
- { "km", "Khmer", LeftToRight },
- { "kn", "Kannada", LeftToRight },
- { "ko", "Korean", LeftToRight },
- { "ks", "Kashmiri", RightToLeft },
- { "la", "Latin", LeftToRight },
- { "lo", "Lao", LeftToRight },
- { "lt", "Lithuanian", LeftToRight },
- { "lv", "Latvian", LeftToRight },
- { "mi", "Maori", LeftToRight },
- { "mk", "FYRO Macedonia", LeftToRight },
- { "ml", "Malayalam", LeftToRight },
- { "mn", "Mongolian", LeftToRight },
- { "mr", "Marathi", LeftToRight },
- { "ms", "Malay", LeftToRight },
- { "mt", "Maltese", LeftToRight },
- { "my", "Burmese", LeftToRight },
- { "nb", "Norwegian: Bokml", LeftToRight },
- { "ne", "Nepali", LeftToRight },
- { "nl", "Dutch", LeftToRight },
- { "nn", "Norwegian: Nynorsk", LeftToRight },
- { "or", "Oriya", LeftToRight },
- { "pa", "Punjabi", LeftToRight },
- { "pl", "Polish", LeftToRight },
- { "pt", "Portuguese", LeftToRight },
- { "rm", "Raeto-Romance", LeftToRight },
- { "ro", "Romanian", LeftToRight },
- { "ru", "Russian", LeftToRight },
- { "sa", "Sanskrit", LeftToRight },
- { "sb", "Sorbian", LeftToRight },
- { "sd", "Sindhi", LeftToRight },
- { "si", "Sinhala", LeftToRight },
- { "sk", "Slovak", LeftToRight },
- { "sl", "Slovenian", LeftToRight },
- { "so", "Somali", LeftToRight },
- { "sq", "Albanian", LeftToRight },
- { "sr", "Serbian", LeftToRight },
- { "sv", "Swedish", LeftToRight },
- { "sw", "Swahili", LeftToRight },
- { "ta", "Tamil", LeftToRight },
- { "te", "Telugu", LeftToRight },
- { "tg", "Tajik", RightToLeft },
- { "th", "Thai", LeftToRight },
- { "tk", "Turkmen", LeftToRight },
- { "tn", "Setsuana", LeftToRight },
- { "tr", "Turkish", LeftToRight },
- { "ts", "Tsonga", LeftToRight },
- { "tt", "Tatar", LeftToRight },
- { "uk", "Ukrainian", LeftToRight },
- { "ur", "Urdu", RightToLeft },
- { "uz", "Uzbek", LeftToRight },
- { "vi", "Vietnamese", LeftToRight },
- { "xh", "Xhosa", LeftToRight },
- { "yi", "Yiddish", RightToLeft },
- { "zh", "Chinese", LeftToRight },
- { "zu", "Zulu", LeftToRight },
-
- { NULL, NULL, LeftToRight }
-};
-
-} // unnamed namespace
-
-TextDirection GetTextDirection( std::string locale )
-{
- TextDirection direction( LeftToRight );
-
- if ( !locale.empty() && locale.size() > 2 )
- {
- // We're only interested in the first two characters
- locale.resize(2);
-
- for ( const LocaleDirection* iter = &LOCALE_DIRECTION_LOOKUP_TABLE[0]; iter->locale; ++iter )
- {
- if ( !locale.compare( iter->locale ) )
- {
- direction = iter->direction;
- break;
- }
- }
- }
-
- return direction;
-}
-
-} // namespace Locale
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_LOCALE_UTILS_H__
-#define __DALI_INTERNAL_LOCALE_UTILS_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-#include <dali/public-api/adaptor-framework/common/virtual-keyboard.h>
-
-// INTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace Locale
-{
-
-Dali::VirtualKeyboard::TextDirection GetTextDirection( std::string locale );
-
-} // namespace Locale
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_LOCALE_UTILS_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "native-bitmap-buffer-impl.h"
-
-// EXTERNAL HEADERS
-#include <dali/integration-api/debug.h>
-#include <dali/integration-api/bitmap.h>
-
-// INTERNAL HEADERS
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-NativeBitmapBuffer::NativeBitmapBuffer( Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pFormat )
-: mWidth(width),
- mHeight(height),
- mPixelFormat(pFormat),
- mLastReadBuffer(NULL)
-{
- DALI_ASSERT_ALWAYS( adaptor );
- mBuffer = new Integration::LocklessBuffer( width * height * Pixel::GetBytesPerPixel(pFormat) );
- mGlAbstraction = &(adaptor->GetGlAbstraction());
-}
-
-NativeBitmapBuffer::~NativeBitmapBuffer()
-{
- delete mBuffer;
-}
-
-void NativeBitmapBuffer::PrepareTexture()
-{
- DALI_ASSERT_ALWAYS( mBuffer );
- GLenum pixelFormat = GL_RGBA;
- GLenum pixelDataType = GL_UNSIGNED_BYTE;
-
- Integration::ConvertToGlFormat( mPixelFormat, pixelDataType, pixelFormat );
-
- const unsigned char* buf = mBuffer->Read();
-
- if( buf && buf != mLastReadBuffer ) // Prevent same buffer being uploaded multiple times
- {
- mLastReadBuffer = buf;
-
- // The active texture has already been set to a sampler and bound.
- mGlAbstraction->TexImage2D( GL_TEXTURE_2D, 0, pixelFormat, mWidth, mHeight, 0, pixelFormat, pixelDataType, buf );
- }
-}
-
-void NativeBitmapBuffer::Write( const unsigned char *src, size_t size )
-{
- mBuffer->Write( src, size ); // Write will cause LocklessBuffer to switch to the other buffer
-}
-
-bool NativeBitmapBuffer::GlExtensionCreate()
-{
- return true;
-}
-
-void NativeBitmapBuffer::GlExtensionDestroy()
-{
-}
-
-unsigned int NativeBitmapBuffer::TargetTexture()
-{
- return 0;
-}
-
-unsigned int NativeBitmapBuffer::GetWidth() const
-{
- return mWidth;
-}
-
-unsigned int NativeBitmapBuffer::GetHeight() const
-{
- return mHeight;
-}
-
-Pixel::Format NativeBitmapBuffer::GetPixelFormat() const
-{
- return mPixelFormat;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_NATIVE_BITMAP_BUFFER_H__
-#define __DALI_NATIVE_BITMAP_BUFFER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL HEADERS
-#include <dali/public-api/images/native-image.h>
-#include <dali/public-api/images/pixel.h>
-#include <dali/integration-api/gl-abstraction.h>
-#include <dali/integration-api/lockless-buffer.h>
-#include <dali/public-api/common/dali-vector.h>
-
-// INTERNAL HEADERS
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class NativeBitmapBuffer;
-typedef IntrusivePtr<NativeBitmapBuffer> NativeBitmapBufferPtr;
-
-/**
- * A Bitmap-based implementation of the NativeImage interface.
- */
-class NativeBitmapBuffer : public NativeImage
-{
-
-public:
- /**
- * Constructor.
- * @param adaptor Adaptor used
- * @param width width of image
- * @param height height of image
- * @param pixelFormat pixel format for image
- */
- NativeBitmapBuffer( Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pixelFormat );
-
- /**
- * virtual destructor
- */
- virtual ~NativeBitmapBuffer();
-
- /**
- * Write to buffer. Does not block.
- * @param[in] src data source
- * @param[in] size size of data in bytes
- * @return true if successful, false if currently reading from buffer in render thread
- */
- void Write( const unsigned char* src, size_t size );
-
-public:
- /**
- * @copydoc Dali::NativeImage::GlExtensionCreate()
- */
- virtual bool GlExtensionCreate();
-
- /**
- * @copydoc Dali::NativeImage::GlExtensionDestroy()
- */
- virtual void GlExtensionDestroy();
-
- /**
- * @copydoc Dali::NativeImage::TargetTexture()
- */
- virtual unsigned int TargetTexture();
-
- /**
- * @copydoc Dali::NativeImage::PrepareTexture()
- */
- virtual void PrepareTexture();
-
- /**
- * @copydoc Dali::NativeImage::GetWidth()
- */
- virtual unsigned int GetWidth() const;
-
- /**
- * @copydoc Dali::NativeImage::GetHeight()
- */
- virtual unsigned int GetHeight() const;
-
- /**
- * @copydoc Dali::NativeImage::GetPixelFormat()
- */
- virtual Pixel::Format GetPixelFormat() const;
-
-private:
- NativeBitmapBuffer( const NativeBitmapBuffer& ); ///< not defined
- NativeBitmapBuffer& operator =( const NativeBitmapBuffer& ); ///< not defined
- NativeBitmapBuffer(); ///< not defined
-
-private:
- Integration::GlAbstraction* mGlAbstraction; ///< GlAbstraction used
-
- Integration::LocklessBuffer* mBuffer; ///< bitmap data double buffered
- unsigned int mWidth; ///< Image width
- unsigned int mHeight; ///< Image height
- Pixel::Format mPixelFormat; ///< Image pixelformat
- const unsigned char* mLastReadBuffer; ///< last buffer that was read
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_NATIVE_BITMAP_BUFFER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "object-profiler.h"
-#include <stdlib.h>
-#include <dali/integration-api/debug.h>
-#include <dali/integration-api/profiling.h>
-#include <dali/public-api/actors/image-actor.h>
-#include <dali/public-api/common/stage.h>
-#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/object/type-registry.h>
-
-using std::string;
-using namespace Dali::Integration::Profiling;
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-ObjectProfiler::ObjectProfiler()
-: mIsActive(false)
-{
- // This class must be created after the Stage; this means it doesn't count the initial objects
- // that are created by the stage (base layer, default camera actor)
- mObjectRegistry = Dali::Stage::GetCurrent().GetObjectRegistry();
-
- char* profile = getenv("PROFILE_DALI_OBJECTS");
- if( profile != NULL )
- {
- mIsActive = true;
- int timeInterval = atoi(profile);
- if( timeInterval > 0 )
- {
- mTimer = Dali::Timer::New(timeInterval*1000);
- mTimer.TickSignal().Connect( this, &ObjectProfiler::OnTimeout );
- mTimer.Start();
- }
-
- mObjectRegistry.ObjectCreatedSignal().Connect( this, &ObjectProfiler::OnObjectCreated );
- mObjectRegistry.ObjectDestroyedSignal().Connect( this, &ObjectProfiler::OnObjectDestroyed );
- }
-}
-
-ObjectProfiler::~ObjectProfiler()
-{
-}
-
-void ObjectProfiler::DisplayInstanceCounts()
-{
- InstanceCountMapIterator iter = mInstanceCountMap.begin();
- InstanceCountMapIterator end = mInstanceCountMap.end();
-
- for( ; iter != end; iter++ )
- {
- int memorySize = GetMemorySize(iter->first, iter->second);
- if( memorySize > 0 )
- {
- LogMessage( Debug::DebugInfo, "%-30s: % 4d Memory MemorySize: ~% 6.1f kB\n",
- iter->first.c_str(), iter->second, memorySize / 1024.0f );
- }
- else
- {
- LogMessage( Debug::DebugInfo, "%-30s: % 4d\n",
- iter->first.c_str(), iter->second );
- }
- }
- LogMessage(Debug::DebugInfo, "\n");
-
- int quadCount = 0;
-
- // Count number of quads:
-
- for( InstanceTypes::iterator iter = mInstanceTypes.begin(), end = mInstanceTypes.end(); iter != end; ++iter )
- {
- if( iter->second.compare("ImageActor") == 0 )
- {
- BaseHandle handle(iter->first);
- Dali::ImageActor imageActor = Dali::ImageActor::DownCast(handle);
- if( imageActor )
- {
- if( imageActor.GetStyle() == Dali::ImageActor::STYLE_QUAD )
- {
- quadCount++;
- }
- }
- }
- }
-
- LogMessage(Debug::DebugInfo, "Number of image actors using Quad style: %d\n", quadCount);
-}
-
-bool ObjectProfiler::OnTimeout()
-{
- DisplayInstanceCounts();
- return true;
-}
-
-void ObjectProfiler::OnObjectCreated(BaseHandle handle)
-{
- string theType = handle.GetTypeName();
- if( theType.empty() )
- {
- DALI_LOG_ERROR("Object created from an unregistered type\n");
- theType = "<Unregistered>";
- }
-
- mInstanceTypes.push_back(InstanceTypePair(&handle.GetBaseObject(), theType));
-
- InstanceCountMapIterator iter = mInstanceCountMap.find(theType);
- if( iter == mInstanceCountMap.end() )
- {
- InstanceCountPair instanceCount(theType, 1);
- mInstanceCountMap.insert(instanceCount);
- }
- else
- {
- iter->second++;
- }
-}
-
-void ObjectProfiler::OnObjectDestroyed(const Dali::RefObject* object)
-{
- const BaseObject* baseObject = static_cast<const BaseObject*>(object);
-
- InstanceTypes::iterator end = mInstanceTypes.end();
- for( InstanceTypes::iterator iter = mInstanceTypes.begin(); iter != end; iter++)
- {
- if( iter->first == baseObject )
- {
- const std::string& theType = iter->second;
- if( !theType.empty() )
- {
- InstanceCountMapIterator countIter = mInstanceCountMap.find(theType);
- if( countIter != mInstanceCountMap.end() )
- {
- countIter->second--;
- }
- }
- mInstanceTypes.erase( iter );
- break;
- }
- }
-}
-
-int ObjectProfiler::GetMemorySize(const std::string& name, int count)
-{
- struct MemoryMemorySize
- {
- std::string name;
- int memorySize;
- };
- MemoryMemorySize memoryMemorySizes[] =
- {
- { "Animation", ANIMATION_MEMORY_SIZE },
- { "Constraint", CONSTRAINT_MEMORY_SIZE },
- { "Actor", ACTOR_MEMORY_SIZE },
- { "Layer", LAYER_MEMORY_SIZE },
- { "CameraActor", CAMERA_ACTOR_MEMORY_SIZE },
- { "ImageActor", IMAGE_ACTOR_MEMORY_SIZE },
- { "TextActor", TEXT_ACTOR_MEMORY_SIZE },
- { "MeshActor", MESH_ACTOR_MEMORY_SIZE },
- { "Image", IMAGE_MEMORY_SIZE },
- { "Mesh", MESH_MEMORY_SIZE },
- { "Material", MATERIAL_MEMORY_SIZE },
- };
-
- for( size_t i=0; i<sizeof(memoryMemorySizes)/sizeof(MemoryMemorySize); i++ )
- {
- if( memoryMemorySizes[i].name.compare(name) == 0 )
- {
- return count * memoryMemorySizes[i].memorySize;
- }
- }
- return 0;
-}
-
-} // Adaptor
-} // Internal
-} // Dali
+++ /dev/null
-#ifndef __DALI_ADAPTOR_OBJECT_PROFILER_H__
-#define __DALI_ADAPTOR_OBJECT_PROFILER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/public-api/object/object-registry.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/common/map-wrapper.h>
-#include <dali/public-api/signals/connection-tracker.h>
-#include <dali/public-api/adaptor-framework/common/timer.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-/**
- * Class to profile the number of instances of Objects in the system
- */
-class ObjectProfiler : public ConnectionTracker
-{
-public:
- /**
- * Constructor
- */
- ObjectProfiler();
-
- /**
- * Destructor
- */
- ~ObjectProfiler();
-
- /**
- * Display a list of types with the current number of instances in the system
- */
- void DisplayInstanceCounts();
-
-private:
- /**
- * If timer is running, display the instance counts
- */
- bool OnTimeout();
-
- /**
- * Callback used when objects are created. Increases instance count for that object type
- * @param[in] handle of the created object
- */
- void OnObjectCreated(BaseHandle handle);
-
- /**
- * Callback used when objects are created. Decreases instance count for that object type
- * @param[in] object The object being destroyed
- */
- void OnObjectDestroyed(const Dali::RefObject* object);
-
- /**
- * Get the memory size of the given object
- */
- int GetMemorySize(const std::string& name, int count);
-
-private:
- typedef std::map<std::string, int> InstanceCountMap;
- typedef std::pair<const std::string, int> InstanceCountPair;
- typedef InstanceCountMap::iterator InstanceCountMapIterator;
- typedef std::pair<BaseObject*, std::string> InstanceTypePair;
- typedef std::vector<InstanceTypePair> InstanceTypes;
-
- Dali::ObjectRegistry mObjectRegistry;
- Dali::Timer mTimer;
- InstanceCountMap mInstanceCountMap;
- InstanceTypes mInstanceTypes;
- bool mIsActive;
-};
-
-} // Adaptor
-} // Internal
-} // Dali
-
-#endif // __DALI_ADAPTOR_OBJECT_PROFILER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "orientation-impl.h"
-
-// EXTERNAL INCLUDES
-#include <Ecore.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/window-impl.h>
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-Orientation* Orientation::New(Window* window)
-{
- Orientation* orientation = new Orientation(window);
-
- return orientation;
-}
-
-Orientation::Orientation(Window* window)
-: mWindow(window),
- mOrientation(0),
- mWindowWidth(0),
- mWindowHeight(0)
-{
-}
-
-Orientation::~Orientation()
-{
- // Note, there is only one orientation object that's owned by window,
- // so it will live longer than adaptor. (hence, no need to remove rotation observer)
-}
-
-void Orientation::SetAdaptor(Dali::Adaptor& adaptor)
-{
- Adaptor::GetImplementation(adaptor).SetRotationObserver(this);
-}
-
-int Orientation::GetDegrees() const
-{
- return mOrientation;
-}
-
-float Orientation::GetRadians() const
-{
- return Math::PI * (float)mOrientation / 180.0f;
-}
-
-Orientation::OrientationSignalV2& Orientation::ChangedSignal()
-{
- return mChangedSignal;
-}
-
-void Orientation::OnRotationPrepare( const RotationEvent& rotation )
-{
- mOrientation = rotation.angle;
- mWindowWidth = rotation.width;
- mWindowHeight = rotation.height;
-}
-
-void Orientation::OnRotationRequest()
-{
- // Emit signal
- if( !mChangedSignal.Empty() )
- {
- Dali::Orientation handle( this );
- mChangedSignal.Emit( handle );
- }
-
- if( mWindow != NULL )
- {
- mWindow->RotationDone( mOrientation, mWindowWidth, mWindowHeight );
- }
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ORIENTATION_H__
-#define __DALI_INTERNAL_ORIENTATION_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <cmath>
-#include <dali/public-api/common/constants.h>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/adaptor-framework/common/orientation.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/rotation-observer.h>
-
-namespace Dali
-{
-class Adaptor;
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-class Window;
-class Orientation;
-
-typedef IntrusivePtr<Orientation> OrientationPtr;
-
-class Orientation : public BaseObject, public RotationObserver
-{
-public:
-
- typedef Dali::Orientation::OrientationSignalV2 OrientationSignalV2;
-
- static Orientation* New(Window* window);
-
- /**
- * Constructor
- */
- Orientation(Window* window);
-
-protected:
- /**
- * Destructor
- */
- virtual ~Orientation();
-
-public:
- /**
- * Set the adaptor for basic setup
- * @param[in] adaptor The adaptor
- */
- void SetAdaptor(Dali::Adaptor& adaptor);
-
- /**
- * Returns the actual orientation in degrees
- * @return The device's orientation
- */
- int GetDegrees() const;
-
- /**
- * Returns the actual orientation in radians
- * @return The device's orientation
- */
- float GetRadians() const;
-
-public: // Signals
-
- /**
- * @copydoc Dali::Orientation::ChangedSignal()
- */
- OrientationSignalV2& ChangedSignal();
-
-private:
- /**
- * @copydoc Dali::Internal::Adaptor::RotationObserver::OnRotationPrepare()
- */
- virtual void OnRotationPrepare( const RotationEvent& rotation );
-
- /**
- * @copydoc Dali::Internal::Adaptor::RotationObserver::OnRotationRequest()
- */
- virtual void OnRotationRequest( );
-
- // Undefined
- Orientation(const Orientation&);
- Orientation& operator=(Orientation&);
-
-private:
- /**
- * Signals and sends event of orientation change.
- */
- void EmitOrientationChange();
-
-private:
-
- Window* mWindow;
-
- OrientationSignalV2 mChangedSignal;
-
- int mOrientation;
- int mWindowWidth;
- int mWindowHeight;
-};
-
-inline Orientation& GetImplementation (Dali::Orientation& orientation)
-{
- DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
-
- BaseObject& handle = orientation.GetBaseObject();
-
- return static_cast<Orientation&>(handle);
-}
-
-inline const Orientation& GetImplementation(const Dali::Orientation& orientation)
-{
- DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
-
- const BaseObject& handle = orientation.GetBaseObject();
-
- return static_cast<const Orientation&>(handle);
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ORIENTATION_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-
-// CLASS HEADER
-#include <internal/common/physical-keyboard-impl.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-Dali::PhysicalKeyboard PhysicalKeyboard::New()
-{
- Dali::PhysicalKeyboard keyboardHandle;
-
- if ( Adaptor::IsAvailable() )
- {
- Dali::Adaptor& adaptor = Adaptor::Get();
- keyboardHandle = Dali::PhysicalKeyboard( new PhysicalKeyboard() );
- adaptor.RegisterSingleton( typeid( keyboardHandle ), keyboardHandle );
- }
-
- return keyboardHandle;
-}
-
-Dali::PhysicalKeyboard PhysicalKeyboard::Get()
-{
- Dali::PhysicalKeyboard keyboardHandle;
-
- // Ensure the adaptor has been created
- if ( Adaptor::IsAvailable() )
- {
- Dali::Adaptor& adaptor = Adaptor::Get();
-
- BaseHandle handle = adaptor.GetSingleton( typeid( Dali::PhysicalKeyboard ) );
- if( handle )
- {
- // If so, downcast the handle of singleton to focus manager
- keyboardHandle = Dali::PhysicalKeyboard( dynamic_cast< PhysicalKeyboard* >( handle.GetObjectPtr() ) );
- }
- }
-
- return keyboardHandle;
-}
-
-bool PhysicalKeyboard::IsAttached() const
-{
- return mAttached;
-}
-
-void PhysicalKeyboard::KeyReceived( bool fromPhysicalKeyboard )
-{
- if ( mAttached != fromPhysicalKeyboard )
- {
- mAttached = fromPhysicalKeyboard;
-
- Dali::PhysicalKeyboard handle( this );
- mStatusChangedSignal.Emit( handle );
- }
-}
-
-PhysicalKeyboard::~PhysicalKeyboard()
-{
-}
-
-PhysicalKeyboard::PhysicalKeyboard()
-: mAttached( false )
-{
-}
-
-} // Adaptor
-
-} // Internal
-
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_PHYSICAL_KEYBOARD_H__
-#define __DALI_INTERNAL_PHYSICAL_KEYBOARD_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-object.h>
-
-// INTERNAL INCLUDES
-#include <public-api/adaptor-framework/common/physical-keyboard.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class PhysicalKeyboard : public BaseObject
-{
-public:
-
- /**
- * Creates a new instance of the PhysicalKeyboard.
- */
- static Dali::PhysicalKeyboard New();
-
- /**
- * Gets the singleton instance of the Physical Keyboard.
- */
- static Dali::PhysicalKeyboard Get();
-
- /**
- * @copydoc Dali::PhysicalKeyboard::IsAttached()
- */
- bool IsAttached() const;
-
- /**
- * Should be called by the EventHandler when a key is received. If it's received from a physical
- * keyboard then the parameter should be true.
- * @param[in] fromPhysicalKeyboard true if received from a physical keyboard, false otherwise.
- */
- void KeyReceived( bool fromPhysicalKeyboard );
-
- // Signals
-
- /**
- * @copydoc Dali::PhysicalKeyboard::StatusChangedSignal()
- */
- Dali::PhysicalKeyboard::Signal& StatusChangedSignal() { return mStatusChangedSignal; }
-
-protected:
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~PhysicalKeyboard();
-
-private:
-
- // Undefined
- PhysicalKeyboard( const PhysicalKeyboard& );
- PhysicalKeyboard& operator=( PhysicalKeyboard& );
-
- /**
- * Constructor
- */
- PhysicalKeyboard();
-
-private:
-
- Dali::PhysicalKeyboard::Signal mStatusChangedSignal; ///< Status changed signal
- bool mAttached; ///< true if the physical keyboard is attached, false otherwise
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-
-inline static Internal::Adaptor::PhysicalKeyboard& GetImplementation( PhysicalKeyboard& keyboard )
-{
- DALI_ASSERT_ALWAYS( keyboard && "PhysicalKeyboard handle is empty" );
-
- BaseObject& handle = keyboard.GetBaseObject();
-
- return static_cast< Internal::Adaptor::PhysicalKeyboard& >( handle );
-}
-
-inline static const Internal::Adaptor::PhysicalKeyboard& GetImplementation( const PhysicalKeyboard& keyboard )
-{
- DALI_ASSERT_ALWAYS( keyboard && "PhysicalKeyboard handle is empty" );
-
- const BaseObject& handle = keyboard.GetBaseObject();
-
- return static_cast< const Internal::Adaptor::PhysicalKeyboard& >( handle );
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_PHYSICAL_KEYBOARD_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "pixmap-image-impl.h"
-
-// EXTERNAL INCLUDES
-#include <Ecore_X.h>
-#include <X11/Xutil.h>
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/adaptor-framework/common/render-surface.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/gl/egl-image-extensions.h>
-#include <internal/common/gl/egl-factory.h>
-#include <internal/common/adaptor-impl.h>
-
-// Allow this to be encoded and saved:
-#include <platform-abstractions/slp/resource-loader/resource-loader.h>
-#include <platform-abstractions/slp/resource-loader/loader-jpeg.h>
-#include <platform-abstractions/slp/resource-loader/loader-png.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-using Dali::Integration::PixelBuffer;
-
-// Pieces needed to save compressed images (temporary location while plumbing):
-namespace
-{
-
- /**
- * Free an allocated XImage on destruction.
- */
- struct XImageJanitor
- {
- XImageJanitor( XImage* const pXImage ) : mXImage( pXImage )
- {
- DALI_ASSERT_DEBUG(pXImage != 0 && "Null pointer to XImage.");
- }
-
- ~XImageJanitor()
- {
- if( mXImage )
- {
- if( !XDestroyImage(mXImage) )
- {
- DALI_ASSERT_DEBUG("XImage deallocation failure");
- }
- }
- }
- XImage* const mXImage;
- private:
- XImageJanitor( const XImageJanitor& rhs );
- XImageJanitor& operator = ( const XImageJanitor& rhs );
- };
-
- /**
- * Simple function to tell intended image file format from filename
- */
- FileFormat GetFormatFromFileName( const std::string& filename )
- {
- if (filename.length() < 5)
- {
- DALI_LOG_WARNING("Invalid (short) filename.");
- }
- FileFormat format(INVALID_FORMAT);
-
- const std::size_t filenameSize = filename.length();
-
- if(filenameSize >= 4){ // Avoid throwing out_of_range or failing silently if exceptions are turned-off on the compare(). (http://www.cplusplus.com/reference/string/string/compare/)
- if( !filename.compare( filenameSize - 4, 4, ".jpg" )
- || !filename.compare( filenameSize - 4, 4, ".JPG" ) )
- {
- format = JPG_FORMAT;
- }
- else if( !filename.compare( filenameSize - 4, 4, ".png" )
- || !filename.compare( filenameSize - 4, 4, ".PNG" ) )
- {
- format = PNG_FORMAT;
- }
- else if( !filename.compare( filenameSize - 4, 4, ".bmp" )
- || !filename.compare( filenameSize - 4, 4, ".BMP" ) )
- {
- format = BMP_FORMAT;
- }
- else if( !filename.compare( filenameSize - 4, 4, ".gif" )
- || !filename.compare( filenameSize - 4, 4, ".GIF" ) )
- {
- format = GIF_FORMAT;
- }
- else if( !filename.compare( filenameSize - 4, 4, ".ico" )
- || !filename.compare( filenameSize - 4, 4, ".ICO" ) )
- {
- format = ICO_FORMAT;
- }
- else if(filenameSize >= 5){
- if( !filename.compare( filenameSize - 5, 5, ".jpeg" )
- || !filename.compare( filenameSize - 5, 5, ".JPEG" ) )
- {
- format = JPG_FORMAT;
- }
- }
- }
-
- return format;
- }
-
- bool EncodeToFormat( const PixelBuffer* pixelBuffer, std::vector< unsigned char >& encodedPixels, FileFormat formatEncoding, std::size_t width, std::size_t height, Pixel::Format pixelFormat )
- {
- switch( formatEncoding )
- {
- case JPG_FORMAT:
- {
- return SlpPlatform::EncodeToJpeg( pixelBuffer, encodedPixels, width, height, pixelFormat );
- break;
- }
- case PNG_FORMAT:
- {
- return SlpPlatform::EncodeToPng( pixelBuffer, encodedPixels, width, height, pixelFormat );
- break;
- }
- default:
- {
- DALI_LOG_ERROR("Format not supported for image encoding (supported formats are PNG and JPEG)");
- break;
- }
- }
- return false;
- }
-
- bool EncodeToFile(const PixelBuffer * const pixelBuffer, const std::string& filename, const Pixel::Format pixelFormat, const std::size_t width, const std::size_t height)
- {
- DALI_ASSERT_DEBUG(pixelBuffer != 0 && filename.size() > 4 && width > 0 && height > 0);
- std::vector< unsigned char > pixbufEncoded;
- const FileFormat format = GetFormatFromFileName( filename );
- const bool encodeResult = EncodeToFormat( pixelBuffer, pixbufEncoded, format, width, height, pixelFormat );
- if(!encodeResult)
- {
- DALI_LOG_ERROR("Encoding pixels failed");
- return false;
- }
- return SlpPlatform::ResourceLoader::SaveFile( filename, pixbufEncoded );
- }
-}
-
-PixmapImage* PixmapImage::New(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Dali::Adaptor& adaptor, Any pixmap )
-{
- PixmapImage* image = new PixmapImage( width, height, depth, adaptor, pixmap );
- DALI_ASSERT_DEBUG( image && "PixmapImage allocation failed." );
-
- // 2nd phase construction
- if(image) //< Defensive in case we ever compile without exceptions.
- {
- image->Initialize();
- }
-
- return image;
-}
-
-PixmapImage::PixmapImage(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Dali::Adaptor& adaptor, Any pixmap)
-: mWidth(width),
- mHeight(height),
- mOwnPixmap(true),
- mPixmap(0),
- mDisplay(NULL),
- mPixelFormat(Pixel::RGB888),
- mColorDepth(depth),
- mAdaptor(Internal::Adaptor::Adaptor::GetImplementation(adaptor)),
- mEglImageKHR(NULL)
-{
- // assign the pixmap
- mPixmap = GetPixmapFromAny(pixmap);
-}
-
-void PixmapImage::Initialize()
-{
- // Get render-surface being used by Dali
- Dali::RenderSurface& surface = mAdaptor.GetSurface();
-
- // get the X11 display pointer and store it
- // it is used by eglCreateImageKHR, and XFreePixmap
- // Any other display (x-connection) will fail in eglCreateImageKHR
- Any display = surface.GetDisplay();
-
- // the dali display pointer is needed
- mDisplay = AnyCast<Ecore_X_Display*>(display);
-
- // if pixmap has been created outside of X11 Image we can return
- if (mPixmap)
- {
- // we don't own the pixmap
- mOwnPixmap = false;
-
- // find out the pixmap width / height and color depth
- GetPixmapDetails();
- return;
- }
-
- // get the pixel depth
- int depth = GetPixelDepth(mColorDepth);
-
- // set the pixel format
- SetPixelFormat(depth);
-
- // Get the X-Renderable for which the pixmap is created on
- Any renderableSurface = surface.GetSurface();
-
- // if Dali is using a Pixmap or Window to render to it doesn't matter because they have the same
- // underlying type of unsigned long
- Ecore_X_Window daliWindow = AnyCast< Ecore_X_Window >(renderableSurface);
-
- mPixmap = ecore_x_pixmap_new(daliWindow, mWidth, mHeight, depth);
- ecore_x_sync();
-}
-
-PixmapImage::~PixmapImage()
-{
- // Lost the opportunity to call GlExtensionDestroy() if Adaptor is destroyed first
- if( Adaptor::IsAvailable() )
- {
- // GlExtensionDestroy() called from GLCleanup on the render thread. Checking this is done here.
- // (mEglImageKHR is now read/written from different threads although ref counted destruction
- // should mean this isnt concurrent)
- DALI_ASSERT_ALWAYS( NULL == mEglImageKHR && "NativeImage GL resources have not been properly cleaned up" );
- }
-
- if (mOwnPixmap && mPixmap)
- {
- ecore_x_pixmap_free(mPixmap);
- }
-}
-
-Any PixmapImage::GetPixmap(Dali::PixmapImage::PixmapAPI api) const
-{
-
- if (api == Dali::PixmapImage::ECORE_X11)
- {
- // return ecore x11 type
- return Any(mPixmap);
- }
- else
- {
- // return x11 type after casting it
- Pixmap pixmap= static_cast<Pixmap>(mPixmap);
- return Any(pixmap);
- }
-}
-
-Any PixmapImage::GetDisplay() const
-{
- // return ecore x11 type
- return Any(mDisplay);
-}
-
-bool PixmapImage::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
-{
- DALI_ASSERT_DEBUG(sizeof(unsigned) == 4);
- bool success = false;
- width = mWidth;
- height = mHeight;
-
- XImageJanitor xImageJanitor( XGetImage(static_cast<Display*>(mDisplay),
- mPixmap,
- 0, 0, // x,y of subregion to extract.
- width, height, // of suregion to extract.
- 0xFFFFFFFF,
- ZPixmap));
- XImage* const pXImage = xImageJanitor.mXImage;
- DALI_ASSERT_DEBUG(pXImage && "XImage (from pixmap) could not be retrieved from the server");
- if(!pXImage)
- {
- DALI_LOG_ERROR("Could not retrieve Ximage.");
- }
- else
- {
- switch(pXImage->depth)
- {
- // Note, depth is a logical value. On target the framebuffer is still 32bpp
- // (see pXImage->bits_per_pixel) so we go through XGetPixel() and swizzle.
- // Note, this could be the default, fallback case for all depths if *pXImage
- // didn't have blank RGB masks (X bug), but we have to hardcode the masks and
- // shifts instead.
- case 24:
- {
- pixelFormat = Pixel::RGB888;
- pixbuf.resize(width*height*3);
- unsigned char* bufPtr = &pixbuf[0];
-
- for(unsigned y = height-1; y < height; --y)
- {
- for(unsigned x = 0; x < width; ++x, bufPtr+=3)
- {
- const unsigned pixel = XGetPixel(pXImage,x,y);
-
- // store as RGB
- const unsigned blue = pixel & 0xFFU;
- const unsigned green = (pixel >> 8) & 0xFFU;
- const unsigned red = (pixel >> 16) & 0xFFU;
-
- *bufPtr = red;
- *(bufPtr+1) = green;
- *(bufPtr+2) = blue;
- }
- }
- success = true;
- break;
- }
- case 32:
- {
- if(pXImage->data)
- {
- // Sweep through the image, doing a vertical flip, but handling each scanline as
- // an inlined intrinsic/builtin memcpy (should be fast):
- pixbuf.resize(width*height*4);
- unsigned * bufPtr = reinterpret_cast<unsigned *>(&pixbuf[0]);
- const unsigned xDataLineSkip = pXImage->bytes_per_line;
- const size_t copy_count = width * 4;
- pixelFormat = Pixel::BGRA8888;
-
- for(unsigned y = height-1; y < height; --y, bufPtr += width)
- {
- const char * const in = pXImage->data + xDataLineSkip * y;
-
- // Copy a whole scanline at a time:
- DALI_ASSERT_DEBUG( size_t( bufPtr ) >= size_t( &pixbuf[0] ));
- DALI_ASSERT_DEBUG( reinterpret_cast<size_t>( bufPtr ) + copy_count <= reinterpret_cast<size_t>( &pixbuf[pixbuf.size()] ) );
- DALI_ASSERT_DEBUG( in >= pXImage->data );
- DALI_ASSERT_DEBUG( in + copy_count <= pXImage->data + xDataLineSkip * height );
- __builtin_memcpy( bufPtr, in, copy_count );
- }
- success = true;
- }
- else
- {
- DALI_LOG_ERROR("XImage has null data pointer.");
- }
- break;
- }
- // Make a case for 16 bit modes especially to remember that the only reason we don't support them is a bug in X:
- case 16:
- {
- DALI_ASSERT_DEBUG(pXImage->red_mask && pXImage->green_mask && pXImage->blue_mask && "No image masks mean 16 bit modes are not possible.");
- ///! If the above assert doesn't fail in a debug build, the X bug may have been fixed, so revisit this function.
- ///! No break, fall through to the general unsupported format warning below.
- }
- default:
- {
- DALI_LOG_WARNING("Pixmap has unsupported bit-depth for getting pixels: %u", pXImage->depth);
- }
- }
- }
- if(!success)
- {
- DALI_LOG_ERROR("Failed to get pixels from PixmapImage.");
- pixbuf.resize(0);
- width = 0;
- height = 0;
- }
- return success;
-}
-
-bool PixmapImage::EncodeToFile(const std::string& filename) const
-{
- std::vector< unsigned char > pixbuf;
- unsigned int width(0), height(0);
- Pixel::Format pixelFormat;
-
- if(GetPixels(pixbuf, width, height, pixelFormat))
- {
- return Dali::Internal::Adaptor::EncodeToFile(&pixbuf[0], filename, pixelFormat, width, height);
- }
- return false;
-}
-
-bool PixmapImage::GlExtensionCreate()
-{
- // if the image existed previously delete it.
- if (mEglImageKHR != NULL)
- {
- GlExtensionDestroy();
- }
-
- EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
-
- // casting from an unsigned int to a void *, which should then be cast back
- // to an unsigned int in the driver.
- EGLClientBuffer eglBuffer = reinterpret_cast< EGLClientBuffer > (mPixmap);
-
- mEglImageKHR = eglImageExtensions->CreateImageKHR( eglBuffer );
-
- return mEglImageKHR != NULL;
-}
-
-void PixmapImage::GlExtensionDestroy()
-{
- EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
-
- eglImageExtensions->DestroyImageKHR(mEglImageKHR);
-
- mEglImageKHR = NULL;
-}
-
-unsigned int PixmapImage::TargetTexture()
-{
- EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
-
- eglImageExtensions->TargetTextureKHR(mEglImageKHR);
-
- return 0;
-}
-
-int PixmapImage::GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const
-{
- switch (depth)
- {
- case Dali::PixmapImage::COLOR_DEPTH_DEFAULT:
- {
- // Get the default screen depth
- return ecore_x_default_depth_get(ecore_x_display_get(), ecore_x_default_screen_get());
- }
- case Dali::PixmapImage::COLOR_DEPTH_8:
- {
- return 8;
- }
- case Dali::PixmapImage::COLOR_DEPTH_16:
- {
- return 16;
- }
- case Dali::PixmapImage::COLOR_DEPTH_24:
- {
- return 24;
- }
- case Dali::PixmapImage::COLOR_DEPTH_32:
- {
- return 32;
- }
- default:
- {
- DALI_ASSERT_DEBUG(0 && "unknown color enum");
- return 0;
- }
- }
-}
-
-void PixmapImage::SetPixelFormat(int depth)
-{
- // store the pixel format based on the depth
- switch (depth)
- {
- case 8:
- {
- mPixelFormat = Pixel::A8;
- break;
- }
- case 16:
- {
- mPixelFormat = Pixel::RGB565;
- break;
- }
- case 32:
- {
- mPixelFormat = Pixel::RGBA8888;
- break;
- }
- case 24:
- default:
- {
- mPixelFormat = Pixel::RGB888;
- break;
- }
- }
-}
-
-Ecore_X_Pixmap PixmapImage::GetPixmapFromAny(Any pixmap) const
-{
- if (pixmap.Empty())
- {
- return 0;
- }
-
- // see if it is of type x11 pixmap
- if (pixmap.GetType() == typeid (Pixmap))
- {
- // get the x pixmap type
- Pixmap xpixmap = AnyCast<Pixmap>(pixmap);
-
- // cast it to a ecore pixmap type
- return static_cast<Ecore_X_Pixmap>(xpixmap);
- }
- else
- {
- return AnyCast<Ecore_X_Pixmap>(pixmap);
- }
-}
-
-void PixmapImage::GetPixmapDetails()
-{
- int x, y;
-
- // get the width, height and depth
- ecore_x_pixmap_geometry_get(mPixmap, &x, &y, (int*)&mWidth, (int*)&mHeight);
-
- // set the pixel format
- SetPixelFormat(ecore_x_pixmap_depth_get(mPixmap));
-}
-
-EglImageExtensions* PixmapImage::GetEglImageExtensions() const
-{
- EglFactory& factory = mAdaptor.GetEGLFactory();
- EglImageExtensions* egl = factory.GetImageExtensions();
- DALI_ASSERT_DEBUG( egl && "EGL Image Extensions not initialized" );
- return egl;
-}
-
-} // namespace Adaptor
-
-} // namespace internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_PIXMAP_IMAGE_H__
-#define __DALI_INTERNAL_PIXMAP_IMAGE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <Ecore_X.h>
-#include <dali/public-api/adaptor-framework/common/pixmap-image.h>
-
-// INTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-class Adaptor;
-class EglImageExtensions;
-
-/**
- * Dali internal PixmapImage.
- */
-class PixmapImage
-{
-public:
-
- /**
- * Create a new PixmapImage internally.
- * Depending on hardware the width and height may have to be a power of two.
- * @param[in] width The width of the image.
- * @param[in] height The height of the image.
- * @param[in] depth color depth of the pixmap
- * @param[in] adaptor reference to dali adaptor
- * @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
- * @return A smart-pointer to a newly allocated image.
- */
- static PixmapImage* New(unsigned int width,
- unsigned int height,
- Dali::PixmapImage::ColorDepth depth,
- Dali::Adaptor& adaptor,
- Any pixmap);
-
- /**
- * @copydoc Dali::PixmapImage::GetPixmap()
- */
- Any GetPixmap(Dali::PixmapImage::PixmapAPI api) const;
-
- /**
- * @copydoc Dali::PixmapImage::GetDisplay()
- */
- Any GetDisplay() const;
-
- /**
- * @copydoc Dali::PixmapImage::GetPixels()
- */
- bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
-
- /**
- * @copydoc Dali::PixmapImage::EncodeToFile(const std::string& )
- */
- bool EncodeToFile(const std::string& filename) const;
-
- /**
- * destructor
- */
- ~PixmapImage();
-
- /**
- * @copydoc Dali::PixmapImage::GlExtensionCreate()
- */
- bool GlExtensionCreate();
-
- /**
- * @copydoc Dali::PixmapImage::GlExtensionDestroy()
- */
- void GlExtensionDestroy();
-
- /**
- * @copydoc Dali::PixmapImage::TargetTexture()
- */
- unsigned int TargetTexture();
-
- /**
- * @copydoc Dali::PixmapImage::GetWidth()
- */
- unsigned int GetWidth() const
- {
- return mWidth;
- }
-
- /**
- * @copydoc Dali::PixmapImage::GetHeight()
- */
- unsigned int GetHeight() const
- {
- return mHeight;
- }
-
- /**
- * @copydoc Dali::PixmapImage::GetPixelFormat()
- */
- Pixel::Format GetPixelFormat() const
- {
- return mPixelFormat;
- }
-
-private:
-
- /**
- * Private constructor; @see PixmapImage::New()
- * @param[in] width The width of the image.
- * @param[in] height The height of the image.
- * @param[in] colour depth of the pixmap
- * @param[in] adaptor a reference to Dali adaptor
- * @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
- */
- PixmapImage(unsigned int width,
- unsigned int height,
- Dali::PixmapImage::ColorDepth depth,
- Dali::Adaptor &adaptor,
- Any pixmap);
-
- /**
- * 2nd phase construction.
- */
- void Initialize();
-
- /**
- * Uses X11 to get the default depth.
- * @param depth the PixelImage depth enum
- * @return default x11 pixel depth
- */
- int GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const;
-
- /**
- * Sets the pixel format based on the bit depth
- * @param depth depth in bytes
- */
- void SetPixelFormat(int depth);
-
- /**
- * Gets the pixmap from the Any parameter
- * @param pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
- * @return pixmap x11 pixmap
- */
- Ecore_X_Pixmap GetPixmapFromAny(Any pixmap) const;
-
- /**
- * Given an existing pixmap, the function uses X to find out
- * the width, heigth and depth of that pixmap.
- */
- void GetPixmapDetails();
-
- /**
- * Returns the egl image extensions class from the adaptor
- * @return reference to egl image extensionsa
- */
- EglImageExtensions* GetEglImageExtensions() const;
-
-private:
-
- unsigned int mWidth; ///< pixmap width
- unsigned int mHeight; ///< pixmap heights
- bool mOwnPixmap; ///< Whether we created pixmap or not
- Ecore_X_Pixmap mPixmap; ///< From Xlib
- Ecore_X_Display* mDisplay; ///< x-connection used to create pixmap (if it was not created outside of PixmapImage)
- Pixel::Format mPixelFormat; ///< pixmap pixel format
- Dali::PixmapImage::ColorDepth mColorDepth; ///< color depth of pixmap
- Adaptor& mAdaptor; ///< adaptor
- void* mEglImageKHR; ///< From EGL extension
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_PIXMAP_IMAGE_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "render-surface-impl.h"
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-RenderSurface::RenderSurface()
-{
-}
-
-RenderSurface::~RenderSurface()
-{
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_RENDER_SURFACE_H__
-#define __DALI_INTERNAL_RENDER_SURFACE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/common/render-surface.h>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/common/view-mode.h>
-
-namespace Dali
-{
-
-namespace Integration
-{
-
-class GlAbstraction;
-
-} // namespace Integration
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class EglInterface;
-
-/**
- * This is the internal RenderSurface API
- */
-class DALI_IMPORT_API RenderSurface : public Dali::RenderSurface
-{
-public:
-
- enum SyncMode
- {
- SYNC_MODE_NONE, ///< Do not wait for RenderSync
- SYNC_MODE_WAIT ///< Wait for RenderSync
- };
-
-public:
-
- /**
- * Constructor
- */
- RenderSurface();
-
- /**
- * Destructor
- */
- virtual ~RenderSurface();
-
-public: // API
-
- /**
- * Initialize EGL, RenderSurface should create egl display and initialize
- * @param egl implementation to use for the creation
- */
- virtual void InitializeEgl( EglInterface& egl ) = 0;
-
- /**
- * Creates EGL Surface
- * @param egl implementation to use for the creation
- */
- virtual void CreateEglSurface( EglInterface& egl ) = 0;
-
- /**
- * Destroyes EGL Surface
- * @param egl implementation to use for the destruction
- */
- virtual void DestroyEglSurface( EglInterface& egl ) = 0;
-
- /**
- * Replace the EGL Surface
- * @param egl implementation to use for the creation
- * @return true if context was lost
- */
- virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
-
- /**
- * Resizes the underlying surface.
- * Only available for x window
- */
- virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
-
- /**
- * Get DPI
- * @param dpiHorizontal set to the horizontal dpi
- * @param dpiVertical set to the vertical dpi
- */
- virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) const = 0;
-
- /**
- * Call to map the surface (only works if surface is a window)
- */
- virtual void Map() = 0;
-
- /**
- * Transfers the ownership of a display
- * @param newSurface to transfer
- */
- virtual void TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface ) = 0;
-
- /**
- * Consumes any possible events on the queue so that there is no leaking between frames
- */
- virtual void ConsumeEvents() = 0;
-
- /**
- * Set the stereoscopic 3D view mode
- * @param[in] viewMode The new view mode
- */
- virtual void SetViewMode( ViewMode viewMode ) = 0;
-
- /**
- * Called after offscreen is posted to onscreen
- */
- virtual void RenderSync() = 0;
-
- /**
- * Invoked by render thread before Core::Render
- * @param[in] egl The Egl interface
- * @param[in] glAbstraction OpenGLES abstraction interface
- * @return True if the operation is successful
- */
- virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) = 0;
-
- /**
- * Invoked by render thread after Core::Render
- * @param[in] egl The Egl interface
- * @param[in] glAbstraction OpenGLES abstraction interface
- * @param[in] deltaTime Time (in microseconds) since PostRender was last called.
- * @param[in] syncMode Wait for render sync flag.
- * RenderSync will be skipped if this or SetSyncMode() is set to SYNC_MODE_NONE.
- */
- virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int deltaTime, SyncMode syncMode ) = 0;
-
- /**
- * Invoked by render thread when the thread should be stop
- */
- virtual void StopRender() = 0;
-
- /**
- * Set whether the surface should wait for RenderSync notifications
- * @param[in] syncMode Wait for render sync flag. A member of SyncMode
- */
- virtual void SetSyncMode( SyncMode syncMode ) = 0;
-};
-
-} // namespace Adaptor
-
-} // namespace internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_RENDER_SURFACE_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_ROTATION_OBSERVER_H__
-#define __DALI_INTERNAL_ROTATION_OBSERVER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-struct RotationEvent
-{
- int angle; ///< one of 0, 90, 180, 270
- int winResize; ///< true if the window should be resized
- int width; ///< new window width
- int height; ///< new window height
-};
-
-
-/**
- * The RotationObserver can be overridden in order to listen to rotation events.
- */
-class RotationObserver
-{
-public:
-
- /**
- * Deriving classes should override this to be notified when we receive a RotationPrepare event.
- * @param[in] area The area that has been rotationd.
- */
- virtual void OnRotationPrepare( const RotationEvent& rotation ) = 0;
-
- /**
- * Deriving classes should override this to be notifed when a RotationRequest event is received
- */
- virtual void OnRotationRequest( ) = 0;
-
-protected:
-
- /**
- * Protected Constructor.
- */
- RotationObserver()
- {
- }
-
- /**
- * Protected virtual destructor.
- */
- virtual ~RotationObserver()
- {
- }
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ROTATION_OBSERVER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "server-connection.h"
-
-// EXTERNAL INCLUDES
-#include <Ecore.h>
-
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-
-namespace
-{
-// Copied from ecore_evas_extn.c
-// procotol version - change this as needed
-const int MAJOR( 0x1011 );
-}
-
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-#if defined(DEBUG_ENABLED)
-extern Debug::Filter* gIndicatorLogFilter;
-#endif
-
-
-ServerConnection::ServerConnection(
- const char* serviceName,
- int serviceNumber,
- bool isSystem,
- ServerConnection::Observer* observer)
-
-: mConnected(false),
- mObserver(observer)
-{
- Ecore_Ipc_Type ipctype = ECORE_IPC_LOCAL_USER;
-
- ecore_ipc_init();
- mService.name = eina_stringshare_add(serviceName);
- mService.num = serviceNumber;
- mService.isSystem = isSystem;
-
- if (mService.isSystem)
- {
- ipctype = ECORE_IPC_LOCAL_SYSTEM;
- }
-
- DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "ServerConnection: Connecting to %s %d\n", mService.name, mService.num );
-
- mIpcServer = ecore_ipc_server_connect( ipctype, (char *)mService.name, mService.num, this );
-
- if( !mIpcServer )
- {
- ecore_ipc_shutdown();
- }
- else
- {
- mIpcHandlers.push_back( ecore_event_handler_add( ECORE_IPC_EVENT_SERVER_ADD,
- &ServerConnection::IpcServerAdd,
- this ) );
-
- mIpcHandlers.push_back( ecore_event_handler_add( ECORE_IPC_EVENT_SERVER_DEL,
- &ServerConnection::IpcServerDel,
- this ) );
-
- mIpcHandlers.push_back( ecore_event_handler_add( ECORE_IPC_EVENT_SERVER_DATA,
- &ServerConnection::IpcServerData,
- this));
-
- mConnected = true;
- }
-}
-
-ServerConnection::~ServerConnection()
-{
- CloseConnection();
-
- if( mService.name != NULL )
- {
- eina_stringshare_del(mService.name);
- }
-
- for( Handlers::iterator iter = mIpcHandlers.begin(); iter != mIpcHandlers.end(); ++iter )
- {
- ecore_event_handler_del(*iter);
- }
- mIpcHandlers.clear();
-}
-
-bool ServerConnection::IsConnected()
-{
- return mConnected;
-}
-
-void ServerConnection::OnDisconnect()
-{
- mConnected = false;
- mIpcServer = NULL;
- ecore_ipc_shutdown();
- if( mObserver )
- {
- mObserver->ConnectionClosed();
- }
-}
-
-bool ServerConnection::SendEvent( int event, const void *data, int size )
-{
- return SendEvent(event, 0, 0, data, size);
-}
-
-bool ServerConnection::SendEvent( int event, int ref, int ref_to, const void *data, int size )
-{
- if( mIpcServer != NULL && ecore_ipc_server_send(mIpcServer, MAJOR, event, ref, ref_to, 0, data, size) )
- {
- return true;
- }
- else
- {
- return false;
- }
-}
-
-Eina_Bool ServerConnection::IpcServerAdd( void *data, int /*type*/, void *event )
-{
- DALI_LOG_INFO(gIndicatorLogFilter, Debug::General, "ServerConnection: IpcServerAdd\n" );
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-Eina_Bool ServerConnection::IpcServerDel( void *data, int /*type*/, void *event )
-{
- DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "ServerConnection: IpcServerDel\n" );
-
- Ecore_Ipc_Event_Server_Del *e = static_cast<Ecore_Ipc_Event_Server_Del *>( event );
- ServerConnection* connection = static_cast<ServerConnection*>( data );
-
- if( connection != NULL )
- {
- if( connection->mIpcServer == e->server)
- {
- // No longer have a server connection
- connection->OnDisconnect();
- }
- }
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-Eina_Bool ServerConnection::IpcServerData( void *data, int /*type*/, void *event )
-{
- DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "ServerConnection: IpcServerData\n" );
-
- Ecore_Ipc_Event_Server_Data *e = static_cast<Ecore_Ipc_Event_Server_Data *>( event );
- ServerConnection* connection = static_cast<ServerConnection*>( data );
-
- if( connection != NULL )
- {
- if( connection != ecore_ipc_server_data_get( e->server ) )
- {
- return ECORE_CALLBACK_PASS_ON;
- }
-
- if( e->major != MAJOR )
- {
- return ECORE_CALLBACK_PASS_ON;
- }
-
- if( connection->mObserver )
- {
- connection->mObserver->DataReceived( event );
- }
- }
- return ECORE_CALLBACK_PASS_ON;
-}
-
-void ServerConnection::CloseConnection()
-{
- if( mConnected )
- {
- DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "ServerConnection: CloseConnection\n" );
-
- if( mIpcServer )
- {
- ecore_ipc_server_del( mIpcServer );
- mIpcServer = NULL;
- }
-
- ecore_ipc_shutdown();
- mConnected = false;
- }
-}
-
-} // Adaptor
-} // Internal
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ADAPTOR_CONNECTION_H_
-#define __DALI_INTERNAL_ADAPTOR_CONNECTION_H_
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <Ecore.h>
-#include <Ecore_Ipc.h>
-
-#include <dali/public-api/common/vector-wrapper.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-/**
- * Makes a connection to a given service as a client
- */
-class ServerConnection
-{
-public:
- /**
- * Observes the connection for data and connection closure
- */
- class Observer
- {
- public:
- /**
- * Inform that data has been received on the connection
- * @param[in] event The event that has been received
- */
- virtual void DataReceived(void* event) = 0;
-
- /**
- * Inform the observer that the connection has closed
- */
- virtual void ConnectionClosed() = 0;
- };
-
-public:
- /**
- * Constructor
- * @param[in] serviceName The name of the service
- * @param[in] serviceNumber The number of the service
- * @param[in] isSystem Whether to connect as local user or system user
- * @param[in] observer The connection observer
- */
- ServerConnection(const char *serviceName, int serviceNumber, bool isSystem, Observer* observer);
-
- /**
- * Destructor
- */
- ~ServerConnection();
-
- /**
- * Test if the connection is still alive
- * @return True if the connection is still alive
- */
- bool IsConnected();
-
- /**
- * Disconnect from the server. Will trigger ConnectionClosed() observer callback
- */
- void OnDisconnect();
-
- /**
- * Send an event to the server.
- * @param[in] event Event id
- * @param[in] data Pointer to the event data
- * @param[in] size Size of the event data
- * @return whether the event is sent successfully or not
- */
- bool SendEvent( int event, const void *data, int size );
-
- /**
- * Send an event to the server.
- * @param[in] event Event id
- * @param[in] ref Message Reference number
- * @param[in] refTo Reference number of the message this refers to
- * @param[in] data Pointer to the event data
- * @param[in] size Size of the event data
- * @return whether the event is sent successfully or not
- */
- bool SendEvent( int event, int ref, int refTo, const void *data, int size );
-
-private: // Class callbacks
- /**
- * Callback when server added
- */
- static Eina_Bool IpcServerAdd(void *data, int type, void *event);
-
- /**
- * Callback when server deleted
- */
- static Eina_Bool IpcServerDel(void *data, int type, void *event);
-
- /**
- * Callback when data available from server
- */
- static Eina_Bool IpcServerData(void *data, int type, void *event);
-
-private:
- void CloseConnection();
-
-private:
- typedef std::vector<Ecore_Event_Handler *> Handlers;
-
- struct Service
- {
- const char *name;
- int num;
- bool isSystem;
- };
-
- Service mService;
- bool mConnected;
- Observer* mObserver;
- Ecore_Ipc_Server* mIpcServer;
- Handlers mIpcHandlers;
-};
-
-} // Adaptor
-} // Internal
-} // Dali
-
-#endif // __DALI_INTERNAL_ADAPTOR_CONNECTION_H_
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "shared-file.h"
-
-// EXTERNAL INCLUDES
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/mman.h>
-
-#include <cstring>
-
-#include <Ecore.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-SharedFile* SharedFile::New(const char* filename, int size, bool isSystem)
-{
- SharedFile *sf = NULL;
-
- sf = new SharedFile;
-
- bool opened = sf->OpenFile( filename, size, isSystem );
- if( !opened )
- {
- delete sf;
- sf = NULL;
- }
- return sf;
-}
-
-SharedFile::SharedFile()
-: mFileDescriptor(-1),
- mSize(0),
- mAddress(NULL),
- mFilename()
-{
-}
-
-SharedFile::~SharedFile()
-{
- Close();
-}
-
-void SharedFile::Close()
-{
- if( mAddress != NULL )
- {
- munmap( mAddress, mSize );
- mAddress = NULL;
- }
-
- if( mFileDescriptor >= 0 )
- {
- close( mFileDescriptor );
- mFileDescriptor = -1;
- }
-}
-
-unsigned char* SharedFile::GetAddress()
-{
- return static_cast<unsigned char *>( mAddress );
-}
-
-bool SharedFile::OpenFile(const char* filename, int size, bool isSystem)
-{
- bool opened = false;
- mode_t mode;
-
- mode = S_IRUSR | S_IWUSR;
- if( isSystem )
- {
- mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
- }
-
- mFileDescriptor = shm_open( filename, O_RDWR, mode );
-
- if( mFileDescriptor >= 0 )
- {
- mFilename = filename;
-
- mSize = size;
- mAddress = mmap( NULL, mSize, PROT_READ | PROT_WRITE, MAP_SHARED, mFileDescriptor, 0 );
-
- if( mAddress != MAP_FAILED )
- {
- opened = true;
- }
- }
- return opened;
-}
-
-} // Adaptor
-} // Internal
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ADAPTOR_SHARED_FILE_H__
-#define __DALI_INTERNAL_ADAPTOR_SHARED_FILE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-class SharedFile
-{
-public:
- /**
- * Open an existing shared file for read/write
- * @return The shared file, or NULL if a file could not be opened and mapped.
- */
- static SharedFile* New( const char* filename, int size, bool isSystem );
-
- /**
- * Constructor
- */
- SharedFile();
-
- /**
- * Destructor
- */
- virtual ~SharedFile();
-
- /**
- * Opens a file for read/write
- * @return true if opened, false on error.
- */
- bool OpenFile( const char* filename, int size, bool isSystem );
-
- /**
- * Close the shared file
- */
- void Close();
-
- /**
- * Get the memory address of the shared file
- * @return the memory address
- */
- unsigned char* GetAddress();
-
-private:
- int mFileDescriptor;
- int mSize;
- void* mAddress;
- std::string mFilename;
-};
-
-} // Adaptor
-} // Internal
-} // Dali
-
-#endif // __DALI_INTERNAL_ADAPTOR_SHARED_FILE_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <internal/common/sound-player-impl.h>
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace // unnamed namespace
-{
-
-// Type Registration
-Dali::BaseHandle Create()
-{
- return SoundPlayer::Get();
-}
-
-Dali::TypeRegistration SOUND_PLAYER_TYPE( typeid(Dali::SoundPlayer), typeid(Dali::BaseHandle), Create );
-
-Dali::SignalConnectorType SIGNAL_CONNECTOR_1( SOUND_PLAYER_TYPE, Dali::SoundPlayer::SIGNAL_SOUND_PLAY_FINISHED, Dali::Internal::Adaptor::SoundPlayer::DoConnectSignal );
-
-} // unnamed namespace
-
-Dali::SoundPlayer SoundPlayer::New()
-{
- Dali::SoundPlayer player = Dali::SoundPlayer( new SoundPlayer() );
- return player;
-}
-
-Dali::SoundPlayer SoundPlayer::Get()
-{
- Dali::SoundPlayer player;
-
- if ( Adaptor::IsAvailable() )
- {
- // Check whether the singleton is already created
- Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::SoundPlayer ) );
- if ( handle )
- {
- // If so, downcast the handle
- player = Dali::SoundPlayer( dynamic_cast< SoundPlayer* >( handle.GetObjectPtr() ) );
- }
- else
- {
- Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
- player = Dali::SoundPlayer( New() );
- adaptorImpl.RegisterSingleton( typeid( player ), player );
- }
- }
-
- return player;
-}
-
-int SoundPlayer::PlaySound( const std::string fileName )
-{
- return mPlugin.PlaySound( fileName );
-}
-
-void SoundPlayer::Stop( int handle )
-{
- mPlugin.StopSound( handle );
-}
-
-SoundPlayer::SoundPlayFinishedSignalV2& SoundPlayer::SoundPlayFinishedSignal()
-{
- return mSoundPlayFinishedSignalV2;
-}
-
-bool SoundPlayer::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
-{
- bool connected( true );
- SoundPlayer* player = dynamic_cast<SoundPlayer*>( object );
-
- if( player &&
- Dali::SoundPlayer::SIGNAL_SOUND_PLAY_FINISHED == signalName )
- {
- player->SoundPlayFinishedSignal().Connect( tracker, functor );
- }
- else
- {
- // signalName does not match any signal
- connected = false;
- }
-
- return connected;
-}
-
-SoundPlayer::SoundPlayer()
-: mPlugin( FeedbackPluginProxy::DEFAULT_OBJECT_NAME )
-{
-}
-
-SoundPlayer::~SoundPlayer()
-{
-}
-
-void SoundPlayer::EmitSoundPlayFinishedSignal()
-{
- // Emit SoundPlayFinished signal
-
- if ( !mSoundPlayFinishedSignalV2.Empty() )
- {
- Dali::SoundPlayer handle( this );
- mSoundPlayFinishedSignalV2.Emit( handle );
- }
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_SOUND_PLAYER_H__
-#define __DALI_INTERNAL_SOUND_PLAYER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-#include <dali/public-api/object/base-object.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/common/sound-player.h>
-#include <internal/common/feedback/feedback-plugin-proxy.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Plays haptic effects.
- */
-class SoundPlayer : public Dali::BaseObject
-{
-
-public:
-
- typedef Dali::SoundPlayer::SoundPlayFinishedSignalV2 SoundPlayFinishedSignalV2;
-
- /**
- * Create a SoundPlayer.
- * @return A newly created SoundPlayer.
- */
- static Dali::SoundPlayer New();
-
- /**
- * Retrieve a handle to the SoundPlayer. This creates an instance if none has been created.
- * @return A handle to the SoundPlayer.
- */
- static Dali::SoundPlayer Get();
-
- /**
- * @copydoc Dali::SoundPlayer::PlaySound()
- */
- int PlaySound(const std::string fileName);
-
- /**
- * @copydoc Dali::SoundPlayer::Stop()
- */
- void Stop(int handle);
-
- /**
- * @copydoc Dali::SoundPlayer::SoundPlayFinishedSignal()
- */
- SoundPlayFinishedSignalV2& SoundPlayFinishedSignal();
-
- /**
- * Connects a callback function with the object's signals.
- * @param[in] object The object providing the signal.
- * @param[in] tracker Used to disconnect the signal.
- * @param[in] signalName The signal to connect to.
- * @param[in] functor A newly allocated FunctorDelegate.
- * @return True if the signal was connected.
- * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
- */
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
-
-private:
-
- /**
- * Private Constructor; see also soundPlayer::New()
- * @param[in] soundPlayer The public sound player class
- */
- SoundPlayer();
-
- /**
- * Destructor
- */
- virtual ~SoundPlayer();
-
- /**
- * Emits the SoundPlayFinished signal.
- */
- void EmitSoundPlayFinishedSignal();
-
- // Undefined
- SoundPlayer(const SoundPlayer&);
-
- // Undefined
- SoundPlayer& operator=(SoundPlayer&);
-
-private:
-
- FeedbackPluginProxy mPlugin;
- SoundPlayFinishedSignalV2 mSoundPlayFinishedSignalV2;
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-
-// Helpers for public-api forwarding methods
-
-inline Internal::Adaptor::SoundPlayer& GetImplementation(Dali::SoundPlayer& player)
-{
- DALI_ASSERT_ALWAYS( player && "SoundPlayer handle is empty" );
-
- BaseObject& handle = player.GetBaseObject();
-
- return static_cast<Internal::Adaptor::SoundPlayer&>(handle);
-}
-
-inline const Internal::Adaptor::SoundPlayer& GetImplementation(const Dali::SoundPlayer& player)
-{
- DALI_ASSERT_ALWAYS( player && "SoundPlayer handle is empty" );
-
- const BaseObject& handle = player.GetBaseObject();
-
- return static_cast<const Internal::Adaptor::SoundPlayer&>(handle);
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_SOUND_PLAYER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "style-monitor-impl.h"
-
-// EXTERNAL INCLUDES
-#include <vconf.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-
-BaseHandle Create()
-{
- BaseHandle handle( StyleMonitor::Get() );
-
- if ( !handle && Adaptor::IsAvailable() )
- {
- Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
- Dali::StyleMonitor styleMonitor = Dali::StyleMonitor( new StyleMonitor( adaptorImpl.GetPlatformAbstraction() ) );
- adaptorImpl.RegisterSingleton( typeid( styleMonitor ), styleMonitor );
- handle = styleMonitor;
- }
-
- return handle;
-}
-TypeRegistration STYLE_MONITOR_TYPE( typeid(Dali::StyleMonitor), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
-
-} // unnamed namespace
-
-Dali::StyleMonitor StyleMonitor::Get()
-{
- Dali::StyleMonitor styleMonitor;
-
- if ( Adaptor::IsAvailable() )
- {
- // Check whether the singleton is already created
- Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::StyleMonitor ) );
- if(handle)
- {
- // If so, downcast the handle
- styleMonitor = Dali::StyleMonitor( dynamic_cast< StyleMonitor* >( handle.GetObjectPtr() ) );
- }
- }
-
- return styleMonitor;
-}
-
-StyleMonitor::StyleMonitor(Integration::PlatformAbstraction& platformAbstraction)
-: mPlatformAbstraction(platformAbstraction)
-{
-}
-
-StyleMonitor::~StyleMonitor()
-{
-}
-
-void StyleMonitor::StyleChanged(StyleChange styleChange)
-{
- if (styleChange.defaultFontChange || styleChange.defaultFontSizeChange)
- {
- mPlatformAbstraction.UpdateDefaultsFromDevice();
- }
-
- EmitStyleChangeSignal(styleChange);
-}
-
-std::string StyleMonitor::GetDefaultFontFamily() const
-{
- return mPlatformAbstraction.GetDefaultFontFamily();
-}
-
-float StyleMonitor::GetDefaultFontSize() const
-{
- return mPlatformAbstraction.GetDefaultFontSize();
-}
-
-const std::string& StyleMonitor::GetTheme() const
-{
- return mUserDefinedThemeFilePath;
-}
-
-void StyleMonitor::SetTheme(const std::string& path)
-{
- StyleChange styleChange;
- styleChange.themeChange = true;
- styleChange.themeFilePath = path;
- mUserDefinedThemeFilePath = path;
-
- EmitStyleChangeSignal(styleChange);
-}
-
-Dali::StyleMonitor::StyleChangeSignalV2& StyleMonitor::StyleChangeSignal()
-{
- return mStyleChangeSignalV2;
-}
-
-void StyleMonitor::EmitStyleChangeSignal(StyleChange styleChange)
-{
- if( !mStyleChangeSignalV2.Empty() )
- {
- Dali::StyleMonitor handle( this );
- mStyleChangeSignalV2.Emit( handle, styleChange );
- }
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_STYLE_MONITOR_H__
-#define __DALI_INTERNAL_STYLE_MONITOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/adaptor-framework/common/style-monitor.h>
-#include <dali/integration-api/platform-abstraction.h>
-
-// INTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * This holds the platform's style information.
- * It provides a signal when any aspect of the default style changes on the device.
- */
-class StyleMonitor : public BaseObject
-{
-public:
-
- // Creation & Destruction
-
- /**
- * Constructor.
- * @param[in] platformAbstraction The platform abstraction.
- */
- StyleMonitor(Integration::PlatformAbstraction& platformAbstraction);
-
- /**
- * Retrieve the initialized instance of the StyleMonitor.
- * @return Handle to StyleMonitor.
- */
- static Dali::StyleMonitor Get();
-
- // Style Change Notifications
-
- /**
- * Informs the Style Monitor that the style has changed.
- * @param[in] styleChange The details of the change.
- */
- void StyleChanged(StyleChange styleChange);
-
- // Style Information
-
- /**
- * @copydoc Dali::StyleMonitor::GetDefaultFontFamily() const
- */
- std::string GetDefaultFontFamily() const;
-
- /**
- * @copydoc Dali::StyleMonitor::GetDefaultFontSize() const
- */
- float GetDefaultFontSize() const;
-
- /**
- * @copydoc Dali::StyleMonitor::GetTheme() const
- */
- const std::string& GetTheme() const;
-
- /**
- * @copydoc Dali::StyleMonitor::SetTheme()
- */
- void SetTheme(const std::string& themeFilePath);
-
- // Signals
-
- /**
- * @copydoc Dali::StyleMonitor::StyleChangeSignal()
- */
- Dali::StyleMonitor::StyleChangeSignalV2& StyleChangeSignal();
-
-protected:
-
- /**
- * Virtual Destructor.
- */
- virtual ~StyleMonitor();
-
-private:
-
- /**
- * Emit the style change signal.
- * @param[in] styleChange The details of the style change
- */
- inline void EmitStyleChangeSignal(StyleChange styleChange);
-
-private:
-
- Dali::StyleMonitor::StyleChangeSignalV2 mStyleChangeSignalV2; ///< Emitted when the style changes
-
- Integration::PlatformAbstraction& mPlatformAbstraction; ///< Reference to the PlatformAbstraction (for retrieving defaults)
- std::string mUserDefinedThemeFilePath;///< String containing the user defined theme file path
-
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-// Additional Helpers for public-api forwarding methods
-
-inline Internal::Adaptor::StyleMonitor& GetImplementation(Dali::StyleMonitor& monitor)
-{
- DALI_ASSERT_ALWAYS(monitor && "Monitor handle is empty");
- BaseObject& handle = monitor.GetBaseObject();
- return static_cast<Internal::Adaptor::StyleMonitor&>(handle);
-}
-
-inline const Internal::Adaptor::StyleMonitor& GetImplementation(const Dali::StyleMonitor& monitor)
-{
- DALI_ASSERT_ALWAYS(monitor && "Monitor handle is empty");
- const BaseObject& handle = monitor.GetBaseObject();
- return static_cast<const Internal::Adaptor::StyleMonitor&>(handle);
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_STYLE_MONITOR_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <system_settings.h>
-#include <Elementary.h>
-
-// INTERNAL INCLUDES
-#include "system-settings.h"
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-int GetLongPressTime( int defaultTime )
-{
- return defaultTime;
-}
-
-int GetElmAccessActionOver()
-{
- // ELM_ACCESS_ACTION_OVER not available in common profile
- return ELM_ACCESS_ACTION_LAST;
-}
-
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_SYSTEM_SETTINGS_H___
-#define __DALI_INTERNAL_SYSTEM_SETTINGS_H___
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-// Get SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY from system setting if available
-int GetLongPressTime( int defaultTime );
-
-// Get ELM_ACCESS_ACTION_OVER from Elementary if available
-int GetElmAccessActionOver();
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_SYSTEM_SETTINGS_H___
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "tilt-sensor-impl.h"
-
-// EXTERNAL INCLUDES
-#include <cmath>
-#include <sensor.h>
-
-#include <dali/public-api/object/type-registry.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/adaptor-impl.h>
-
-#ifdef __arm__
-#define SENSOR_ENABLED
-#endif
-
-namespace // unnamed namespace
-{
-
-const int NUMBER_OF_SAMPLES = 10;
-
-const float MAX_ACCELEROMETER_XY_VALUE = 9.8f;
-
-// Type Registration
-Dali::BaseHandle Create()
-{
- return Dali::Internal::Adaptor::TiltSensor::Get();
-}
-
-Dali::TypeRegistration typeRegistration( typeid(Dali::TiltSensor), typeid(Dali::BaseHandle), Create );
-
-Dali::SignalConnectorType signalConnector1( typeRegistration, Dali::TiltSensor::SIGNAL_TILTED, Dali::Internal::Adaptor::TiltSensor::DoConnectSignal );
-
-} // unnamed namespace
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-Dali::TiltSensor TiltSensor::New()
-{
- Dali::TiltSensor sensor = Dali::TiltSensor(new TiltSensor());
-
- return sensor;
-}
-
-Dali::TiltSensor TiltSensor::Get()
-{
- Dali::TiltSensor sensor;
-
- if ( Adaptor::IsAvailable() )
- {
- // Check whether the keyboard focus manager is already created
- Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::TiltSensor ) );
- if(handle)
- {
- // If so, downcast the handle of singleton to keyboard focus manager
- sensor = Dali::TiltSensor( dynamic_cast< TiltSensor* >( handle.GetObjectPtr() ) );
- }
- else
- {
- // Create a singleton instance
- Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
- sensor = TiltSensor::New();
- adaptorImpl.RegisterSingleton( typeid( sensor ), sensor );
- handle = sensor;
- }
- }
-
- return sensor;
-}
-
-TiltSensor::~TiltSensor()
-{
- Disable();
-}
-
-bool TiltSensor::Enable()
-{
- // Make sure sensor API is responding
- bool success = Update();
-
- if ( success )
- {
- if ( !mTimer )
- {
- mTimer = Dali::Timer::New( 1000.0f / mFrequencyHertz );
- mTimer.TickSignal().Connect( mTimerSlot, &TiltSensor::Update );
- }
-
- if ( mTimer &&
- !mTimer.IsRunning() )
- {
- mTimer.Start();
- }
- }
-
- return success;
-}
-
-void TiltSensor::Disable()
-{
- if ( mTimer )
- {
- mTimer.Stop();
- mTimer.Reset();
- }
-}
-
-bool TiltSensor::IsEnabled() const
-{
- return ( mTimer && mTimer.IsRunning() );
-}
-
-float TiltSensor::GetRoll() const
-{
- return mRoll;
-}
-
-float TiltSensor::GetPitch() const
-{
- return mPitch;
-}
-
-Quaternion TiltSensor::GetRotation() const
-{
- return mRotation;
-}
-
-TiltSensor::TiltedSignalV2& TiltSensor::TiltedSignal()
-{
- return mTiltedSignalV2;
-}
-
-void TiltSensor::SetUpdateFrequency( float frequencyHertz )
-{
- DALI_ASSERT_ALWAYS( frequencyHertz > 0.0f && "Frequency must have a positive value" );
-
- if ( fabsf(mFrequencyHertz - frequencyHertz) >= GetRangedEpsilon(mFrequencyHertz, frequencyHertz) )
- {
- mFrequencyHertz = frequencyHertz;
-
- if ( mTimer )
- {
- mTimer.SetInterval( 1000.0f / mFrequencyHertz );
- }
- }
-}
-
-float TiltSensor::GetUpdateFrequency() const
-{
- return mFrequencyHertz;
-}
-
-void TiltSensor::SetRotationThreshold(Radian rotationThreshold)
-{
- mRotationThreshold = rotationThreshold;
-}
-
-Radian TiltSensor::GetRotationThreshold() const
-{
- return mRotationThreshold;
-}
-
-bool TiltSensor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
-{
- bool connected( true );
- TiltSensor* sensor = dynamic_cast<TiltSensor*>( object );
-
- if( sensor &&
- Dali::TiltSensor::SIGNAL_TILTED == signalName )
- {
- sensor->TiltedSignal().Connect( tracker, functor );
- }
- else
- {
- // signalName does not match any signal
- connected = false;
- }
-
- return connected;
-}
-
-TiltSensor::TiltSensor()
-: mFrequencyHertz( Dali::TiltSensor::DEFAULT_UPDATE_FREQUENCY ),
- mTimerSlot( this ),
- mSensorFrameworkHandle( -1 ),
- mRoll( 0.0f ),
- mPitch( 0.0f ),
- mRotation( 0.0f, Vector3::YAXIS ),
- mRotationThreshold( 0.0f )
-{
- mRollValues.resize( NUMBER_OF_SAMPLES, 0.0f );
- mPitchValues.resize( NUMBER_OF_SAMPLES, 0.0f );
-}
-
-bool TiltSensor::Update()
-{
- float newRoll = 0.0f;
- float newPitch = 0.0f;
- Quaternion newRotation;
-#ifdef SENSOR_ENABLED
-
- // Read accelerometer data
-
- mSensorFrameworkHandle = sf_connect( ACCELEROMETER_SENSOR );
- if ( mSensorFrameworkHandle < 0 )
- {
- DALI_LOG_ERROR( "Failed to connect to sensor framework" );
- return false;
- }
-
- if ( sf_start(mSensorFrameworkHandle, 0) < 0 )
- {
- DALI_LOG_ERROR( "Failed to start sensor" );
- sf_disconnect(mSensorFrameworkHandle);
- return false;
- }
-
- sensor_data_t* base_data_values = (sensor_data_t*)malloc(sizeof(sensor_data_t));
-
- int dataErr = sf_get_data(mSensorFrameworkHandle, ACCELEROMETER_BASE_DATA_SET, base_data_values);
- if ( dataErr < 0 )
- {
- DALI_LOG_ERROR( "Failed to retrieve sensor data" );
- free(base_data_values);
- sf_stop(mSensorFrameworkHandle);
- sf_disconnect(mSensorFrameworkHandle);
- return false;
- }
-
- sf_stop(mSensorFrameworkHandle);
- sf_disconnect(mSensorFrameworkHandle);
-
- mRollValues.push_back( base_data_values->values[0] );
- mRollValues.pop_front();
-
- mPitchValues.push_back( base_data_values->values[1] );
- mPitchValues.pop_front();
-
- free(base_data_values);
- base_data_values = NULL;
-
- float averageRoll( 0.0f );
- for ( std::deque<float>::const_iterator iter = mRollValues.begin(); mRollValues.end() != iter; ++iter )
- {
- averageRoll += *iter;
- }
- averageRoll /= mRollValues.size();
-
- float averagePitch( 0.0f );
- for ( std::deque<float>::const_iterator iter = mPitchValues.begin(); mPitchValues.end() != iter; ++iter )
- {
- averagePitch += *iter;
- }
- averagePitch /= mPitchValues.size();
-
- newRoll = Clamp( float(averageRoll / MAX_ACCELEROMETER_XY_VALUE), -1.0f/*min*/, 1.0f/*max*/ );
- newPitch = Clamp( float(averagePitch / MAX_ACCELEROMETER_XY_VALUE), -1.0f/*min*/, 1.0f/*max*/ );
-
- newRotation = Quaternion( newRoll * Math::PI * -0.5f, Vector3::YAXIS ) *
- Quaternion( newPitch * Math::PI * -0.5f, Vector3::XAXIS );
-#endif // SENSOR_ENABLED
-
- Radian angle(Quaternion::AngleBetween(newRotation, mRotation));
- // If the change in value is more than the threshold then emit tilted signal.
- if( angle > mRotationThreshold )
- {
- mRoll = newRoll;
- mPitch = newPitch;
- mRotation = newRotation;
-
- if ( !mTiltedSignalV2.Empty() )
- {
- Dali::TiltSensor handle( this );
- mTiltedSignalV2.Emit( handle );
- }
- }
-
- return true;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ADAPTOR_TILT_SENSOR_H__
-#define __DALI_INTERNAL_ADAPTOR_TILT_SENSOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <deque>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/adaptor-framework/common/timer.h>
-
-// INTERNAL INCLUDES
-#include <public-api/adaptor-framework/common/tilt-sensor.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * TiltSensor provides pitch & roll values when the device is tilted.
- */
-class TiltSensor : public Dali::BaseObject
-{
-public:
-
- typedef Dali::TiltSensor::TiltedSignalV2 TiltedSignalV2;
-
- /**
- * Create a TiltSensor.
- * This should only be called once by the Adaptor class.
- * @return A newly allocated tilt-sensor.
- */
- static Dali::TiltSensor New();
-
- /**
- * @copydoc Dali::TiltSensor::Get()
- */
- static Dali::TiltSensor Get();
-
- /**
- * @copydoc Dali::TiltSensor::Enable()
- */
- bool Enable();
-
- /**
- * @copydoc Dali::TiltSensor::Disable()
- */
- void Disable();
-
- /**
- * @copydoc Dali::TiltSensor::IsEnabled()
- */
- bool IsEnabled() const;
-
- /**
- * @copydoc Dali::TiltSensor::GetRoll()
- */
- float GetRoll() const;
-
- /**
- * @copydoc Dali::TiltSensor::GetPitch()
- */
- float GetPitch() const;
-
- /**
- * @copydoc Dali::TiltSensor::GetRotation()
- */
- Quaternion GetRotation() const;
-
- /**
- * @copydoc Dali::TiltSensor::TiltedSignal()
- */
- TiltedSignalV2& TiltedSignal();
-
- /**
- * @copydoc Dali::TiltSensor::SetUpdateFrequency()
- */
- void SetUpdateFrequency( float frequencyHertz );
-
- /**
- * @copydoc Dali::TiltSensor::GetUpdateFrequency()
- */
- float GetUpdateFrequency() const;
-
- /**
- * @copydoc Dali::TiltSensor::SetRotationThreshold()
- */
- void SetRotationThreshold(Radian rotationThreshold);
-
- /**
- * @copydoc Dali::TiltSensor::GetRotationThreshold()
- */
- Radian GetRotationThreshold() const;
-
- /**
- * Connects a callback function with the object's signals.
- * @param[in] object The object providing the signal.
- * @param[in] tracker Used to disconnect the signal.
- * @param[in] signalName The signal to connect to.
- * @param[in] functor A newly allocated FunctorDelegate.
- * @return True if the signal was connected.
- * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
- */
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
-
-private:
-
- /**
- * Private constructor; see also TiltSensor::New()
- */
- TiltSensor();
-
- /**
- * Destructor
- */
- virtual ~TiltSensor();
-
- /**
- * Timer callback to update the tilt values
- */
- bool Update();
-
- // Undefined
- TiltSensor(const TiltSensor&);
-
- // Undefined
- TiltSensor& operator=(TiltSensor&);
-
-private:
-
- float mFrequencyHertz;
- Dali::Timer mTimer;
- SlotDelegate< TiltSensor > mTimerSlot;
-
- int mSensorFrameworkHandle;
-
- float mRoll;
- float mPitch;
- Quaternion mRotation;
-
- Radian mRotationThreshold;
-
- std::deque<float> mRollValues;
- std::deque<float> mPitchValues;
-
- TiltedSignalV2 mTiltedSignalV2;
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-
-inline Internal::Adaptor::TiltSensor& GetImplementation(Dali::TiltSensor& sensor)
-{
- DALI_ASSERT_ALWAYS( sensor && "TiltSensor handle is empty" );
-
- BaseObject& handle = sensor.GetBaseObject();
-
- return static_cast<Internal::Adaptor::TiltSensor&>(handle);
-}
-
-inline const Internal::Adaptor::TiltSensor& GetImplementation(const Dali::TiltSensor& sensor)
-{
- DALI_ASSERT_ALWAYS( sensor && "TiltSensor handle is empty" );
-
- const BaseObject& handle = sensor.GetBaseObject();
-
- return static_cast<const Internal::Adaptor::TiltSensor&>(handle);
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ADAPTOR_TILT_SENSOR_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "timer-impl.h"
-
-// EXTERNAL INCLUDES
-#include <Ecore.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-// LOCAL STUFF
-namespace
-{
-Eina_Bool TimerSourceFunc (void *data)
-{
- Timer* timer = static_cast<Timer*>(data);
-
- bool keepRunning = timer->Tick();
-
- return keepRunning ? EINA_TRUE : EINA_FALSE;
-}
-} // unnamed namespace
-
-/**
- * Struct to hide away Ecore implementation details
- */
-struct Timer::Impl
-{
- Impl( unsigned int milliSec )
- : mId(NULL),
- mInterval(milliSec)
- {
- }
-
- Ecore_Timer * mId;
- unsigned int mInterval;
-};
-
-TimerPtr Timer::New( unsigned int milliSec )
-{
- TimerPtr timer( new Timer( milliSec ) );
- return timer;
-}
-
-Timer::Timer( unsigned int milliSec )
-: mImpl(new Impl(milliSec))
-{
-}
-
-Timer::~Timer()
-{
- // stop timers
- Stop();
-
- delete mImpl;
-}
-
-void Timer::Start()
-{
- if(mImpl->mId > 0)
- {
- Stop();
- }
- mImpl->mId = ecore_timer_add( (double)mImpl->mInterval/1000.0f, (Ecore_Task_Cb)TimerSourceFunc, this );
-}
-
-void Timer::Stop()
-{
- if (mImpl->mId != NULL)
- {
- ecore_timer_del(mImpl->mId);
- mImpl->mId = NULL;
- }
-}
-
-void Timer::SetInterval( unsigned int interval )
-{
- // stop existing timer
- Stop();
- mImpl->mInterval = interval;
- // start new tick
- Start();
-}
-
-unsigned int Timer::GetInterval() const
-{
- return mImpl->mInterval;
-}
-
-bool Timer::Tick()
-{
- // Guard against destruction during signal emission
- Dali::Timer handle( this );
-
- bool retVal( false );
-
- // Override with new signal if used
- if( !mTickSignal.Empty() )
- {
- retVal = mTickSignal.Emit();
-
- // Timer stops if return value is false
- if (retVal == false)
- {
- Stop();
- }
- else
- {
- retVal = true; // continue emission
- }
- }
- else // no callbacks registered
- {
- // periodic timer is started but nobody listens, continue
- retVal = true;
- }
-
- return retVal;
-}
-
-Dali::Timer::TimerSignalV2& Timer::TickSignal()
-{
- return mTickSignal;
-}
-
-bool Timer::IsRunning() const
-{
- return mImpl->mId != NULL;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_TIMER_H__
-#define __DALI_INTERNAL_TIMER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/adaptor-framework/common/timer.h>
-
-// INTERNAL INCLUDES
-#include <base/interfaces/timer-interface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-class Timer;
-
-typedef IntrusivePtr<Timer> TimerPtr;
-
-/**
- * Implementation of the timer
- */
-class Timer : public BaseObject, public TimerInterface
-{
-public:
- static TimerPtr New( unsigned int milliSec );
-
- /**
- * Constructor
- * @param[in] milliSec Interval in milliseconds.
- */
- Timer( unsigned int milliSec );
-
- /**
- * Destructor.
- */
- virtual ~Timer();
-
-public:
-
- /**
- * @copydoc Dali::Timer::Start()
- */
- virtual void Start();
-
- /**
- * @copydoc Dali::Timer::Stop()
- */
- virtual void Stop();
-
- /**
- * @copydoc Dali::Timer::SetInterval()
- */
- virtual void SetInterval( unsigned int interval );
-
- /**
- * @copydoc Dali::Timer::GetInterval()
- */
- virtual unsigned int GetInterval() const;
-
- /**
- * @copydoc Dali::Timer::IsRunning()
- */
- virtual bool IsRunning() const;
-
- /**
- * Tick
- */
- bool Tick();
-
-public: // Signals
-
- Dali::Timer::TimerSignalV2& TickSignal();
-
-private: // Implementation
-
- // not implemented
- Timer( const Timer& );
- Timer& operator=( const Timer& );
-
-private: // Data
-
- Dali::Timer::TimerSignalV2 mTickSignal;
-
- // To hide away implementation details
- struct Impl;
- Impl* mImpl;
-};
-
-inline Timer& GetImplementation(Dali::Timer& timer)
-{
- DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
-
- BaseObject& handle = timer.GetBaseObject();
-
- return static_cast<Internal::Adaptor::Timer&>(handle);
-}
-
-inline const Timer& GetImplementation(const Dali::Timer& timer)
-{
- DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
-
- const BaseObject& handle = timer.GetBaseObject();
-
- return static_cast<const Internal::Adaptor::Timer&>(handle);
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_TIMER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "trigger-event-factory.h"
-
-// INTERNAL INCLUDES
-#include <internal/common/trigger-event.h>
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-TriggerEventInterface* TriggerEventFactory::CreateTriggerEvent( boost::function<void()> functor, TriggerEventInterface::Options options )
-{
- return new TriggerEvent( functor, options );
-}
-
-void TriggerEventFactory::DestroyTriggerEvent( TriggerEventInterface* triggerEventInterface )
-{
- TriggerEvent* triggerEvent( static_cast< TriggerEvent* >( triggerEventInterface) );
- delete triggerEvent;
-}
-
-
-} // namespace Internal
-
-} // namespace Adaptor
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ADAPTOR_TRIGGER_EVENT_FACTORY_H__
-#define __DALI_INTERNAL_ADAPTOR_TRIGGER_EVENT_FACTORY_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <base/interfaces/trigger-event-factory-interface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * @brief Trigger interface factory class
- *
- */
-class TriggerEventFactory : public TriggerEventFactoryInterface
-{
-
-public:
-
- /**
- * @brief Constructor
- */
- TriggerEventFactory()
- {
- }
-
- /**
- * @brief Destructor
- */
- virtual ~TriggerEventFactory()
- {
- }
-
- /**
- * @copydoc TriggerEventFactoryInterface::CreateTriggerEvent
- */
- virtual TriggerEventInterface* CreateTriggerEvent( boost::function<void()> functor, TriggerEventInterface::Options options );
-
-
- /**
- * @copydoc TriggerEventFactoryInterface::DestroyTriggerEvent
- */
- virtual void DestroyTriggerEvent( TriggerEventInterface* triggerEventInterface );
-
-};
-
-} // namespace Internal
-
-} // namespace Adaptor
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ADAPTOR_TRIGGER_EVENT_FACTORY_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "trigger-event.h"
-
-// EXTERNAL INCLUDES
-#include <sys/eventfd.h>
-#include <boost/bind.hpp>
-
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-
-#include <internal/common/file-descriptor-monitor.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-TriggerEvent::TriggerEvent( boost::function<void()> functor, TriggerEventInterface::Options options )
-: mFileDescriptorMonitor(NULL),
- mFunctor(functor),
- mFileDescriptor(-1),
- mOptions( options )
-{
- // Create accompanying file descriptor.
- mFileDescriptor = eventfd(0, EFD_NONBLOCK);
- if (mFileDescriptor >= 0)
- {
- // Now Monitor the created event file descriptor
- mFileDescriptorMonitor = new FileDescriptorMonitor(mFileDescriptor, boost::bind(&TriggerEvent::Triggered, this));
- }
- else
- {
- DALI_LOG_ERROR("Unable to create TriggerEvent File descriptor\n");
- }
-}
-
-TriggerEvent::~TriggerEvent()
-{
- if (mFileDescriptorMonitor)
- {
- delete mFileDescriptorMonitor;
- mFileDescriptorMonitor = NULL;
- }
-
- if (mFileDescriptor >= 0)
- {
- close(mFileDescriptor);
- mFileDescriptor = 0;
- }
-}
-
-void TriggerEvent::Trigger()
-{
- if (mFileDescriptor >= 0)
- {
- // Increment event counter by 1.
- // Writing to the file descriptor triggers the Dispatch() method in the other thread
- // (if in multi-threaded environment).
-
- uint64_t data = 1;
- int size = write(mFileDescriptor, &data, sizeof(uint64_t));
-
- if (size != sizeof(uint64_t))
- {
- DALI_LOG_ERROR("Unable to write to UpdateEvent File descriptor\n");
- }
- }
- else
- {
- DALI_LOG_WARNING("Attempting to write to an invalid file descriptor\n");
- }
-}
-
-void TriggerEvent::Triggered()
-{
- // Reading from the file descriptor resets the event counter, we can ignore the count.
- uint64_t receivedData;
- size_t size;
- size = read(mFileDescriptor, &receivedData, sizeof(uint64_t));
- if (size != sizeof(uint64_t))
- {
- DALI_LOG_WARNING("Unable to read to UpdateEvent File descriptor\n");
- }
-
- // Call the connected boost function.
- mFunctor();
-
- //check if we should delete ourselves after the trigger
- if( mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER )
- {
- delete this;
- }
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_TRIGGER_EVENT_H__
-#define __DALI_INTERNAL_TRIGGER_EVENT_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <base/interfaces/trigger-event-interface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class FileDescriptorMonitor;
-
-/**
- * The TriggerEvent class is used to send events between threads. For example, this can be used
- * to wake up one thread from another thread.
- *
- * Typically, these should be created in the application thread.
- *
- * The observer will be informed whenever the event is triggered.
- *
- * The implementation of TriggerEvent uses an event file descriptor.
- */
-class DALI_IMPORT_API TriggerEvent : public TriggerEventInterface
-{
-public:
-
- /**
- * Constructor
- * Creates an event file descriptor and starts a GSource which reads from the file
- * descriptor when there is data.
- *
- * @param[in] functor to call
- * @param[in] options, trigger event options.
- */
- TriggerEvent( boost::function<void()> functor, TriggerEventInterface::Options options = TriggerEventInterface::NONE );
-
- /**
- * Destructor
- */
- ~TriggerEvent();
-
-public:
-
- /**
- * Triggers the event.
- *
- * This can be called from one thread in order to wake up another thread.
- */
- void Trigger();
-
-private:
-
- /**
- * Called when our event file descriptor has been written to.
- */
- void Triggered();
-
-private:
-
- struct Source;
-
-private:
-
- FileDescriptorMonitor* mFileDescriptorMonitor;
- boost::function<void()> mFunctor; ///< Function object to call
- int mFileDescriptor;
- TriggerEventInterface::Options mOptions;
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_TRIGGER_EVENT_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "tts-player-impl.h"
-
-// EXTERNAL INCLUDES
-#include <tts.h>
-#include <stdio.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace // unnamed namespace
-{
-// Type Registration
-Dali::BaseHandle Create()
-{
- return Dali::TtsPlayer::Get() ;
-}
-
-Dali::TypeRegistration mType( typeid(Dali::TtsPlayer), typeid(Dali::BaseHandle), Create ) ;
-} // unnamed namespace
-
-#if defined(DEBUG_ENABLED)
-Debug::Filter* TtsPlayer::gLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_TTS_PLAYER");
-#endif
-
-Dali::TtsPlayer TtsPlayer::New(Dali::TtsPlayer::Mode mode)
-{
- Dali::TtsPlayer player = Dali::TtsPlayer(new TtsPlayer(mode));
-
- return player;
-}
-
-TtsPlayer::TtsPlayer(Dali::TtsPlayer::Mode mode)
-: mInitialized(false),
- mUnplayedString(""),
- mUtteranceId(0),
- mTtsMode(mode)
-{
- Initialize();
-}
-
-TtsPlayer::~TtsPlayer()
-{
- // If it is playing, stop it
- Stop();
-
- // Unset the callback funtion for TTS state change
- int retVal = tts_unset_state_changed_cb(mTtsHandle);
- if( retVal != TTS_ERROR_NONE )
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
-
- // Destroy the TTS handle and disconnects the daemon
- retVal = tts_destroy(mTtsHandle);
- if( retVal != TTS_ERROR_NONE )
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
-}
-
-void TtsPlayer::Initialize()
-{
- // Create the TTS handle
- int retVal = tts_create(&mTtsHandle);
-
- if( retVal != TTS_ERROR_NONE )
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
- else
- {
- // Set the callback funtion for TTS state change
- retVal = tts_set_state_changed_cb(mTtsHandle, &StateChangedCallback, this);
- if( retVal != TTS_ERROR_NONE )
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
-
- // Check tts mode
- tts_mode_e ttsMode = TTS_MODE_DEFAULT;
- switch (mTtsMode)
- {
- case Dali::TtsPlayer::DEFAULT:
- ttsMode = TTS_MODE_DEFAULT;
- break;
- case Dali::TtsPlayer::NOTIFICATION:
- ttsMode = TTS_MODE_NOTIFICATION;
- break;
- case Dali::TtsPlayer::SCREEN_READER:
- ttsMode = TTS_MODE_SCREEN_READER;
- break;
- default:
- break;
- }
-
- // Set mode
- retVal = tts_set_mode(mTtsHandle, ttsMode);
- if(retVal != TTS_ERROR_NONE)
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
-
- // Connect the TTS daemon asynchronously
- retVal = tts_prepare(mTtsHandle);
- if(retVal != TTS_ERROR_NONE)
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
- }
-}
-
-void TtsPlayer::Play(const std::string& text)
-{
- if(mInitialized)
- {
- Stop();
-
- // Add text to the queue, and use normal speed, default language and default voice set by the user
- int retVal = tts_add_text(mTtsHandle, text.c_str(), NULL, TTS_VOICE_TYPE_AUTO, TTS_SPEED_AUTO, &mUtteranceId);
- if(retVal != TTS_ERROR_NONE)
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
- else
- {
- // Start synthesizing voice from text in the queue and play synthesized audio data
- retVal = tts_play(mTtsHandle);
- if(retVal != TTS_ERROR_NONE)
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
- }
- }
- else
- {
- mUnplayedString = text;
- }
-}
-
-void TtsPlayer::Stop()
-{
- if(mInitialized)
- {
- // Check the current TTS state
- tts_state_e state;
- int retVal = tts_get_state(mTtsHandle, &state);
- if(retVal != TTS_ERROR_NONE)
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
- else if(state == TTS_STATE_PLAYING || state == TTS_STATE_PAUSED)
- {
- // If it is playing or paused, stop playing and clear the queue
- retVal = tts_stop(mTtsHandle);
- if( retVal != TTS_ERROR_NONE )
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
- }
- }
-}
-
-void TtsPlayer::Pause()
-{
- if(mInitialized)
- {
- // Check the current TTS state
- tts_state_e state;
- int retVal = tts_get_state(mTtsHandle, &state);
- if(retVal != TTS_ERROR_NONE)
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
- else if(state == TTS_STATE_PLAYING)
- {
- // If the player is playing, pause it.
- retVal = tts_pause(mTtsHandle);
- if( retVal != TTS_ERROR_NONE )
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
- }
- }
-}
-
-void TtsPlayer::Resume()
-{
- if(mInitialized)
- {
- // Check the current TTS state
- tts_state_e state;
- int retVal = tts_get_state(mTtsHandle, &state);
- if(retVal != TTS_ERROR_NONE)
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
- else if(state == TTS_STATE_PAUSED)
- {
- // If the player is paused, resume it.
- retVal = tts_play(mTtsHandle);
- if( retVal != TTS_ERROR_NONE )
- {
- LogErrorCode(static_cast<tts_error_e>(retVal));
- }
- }
- }
-}
-
-void TtsPlayer::StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void *userData)
-{
- TtsPlayer* obj = static_cast<TtsPlayer*>(userData);
- if(!obj->mInitialized && current == TTS_STATE_READY)
- {
- obj->mInitialized = true;
-
- // if there is queued text before initialization, play it
- if(obj->mUnplayedString != "")
- {
- obj->Play(obj->mUnplayedString);
- obj->mUnplayedString = "";
- }
- }
-}
-
-void TtsPlayer::LogErrorCode(tts_error_e reason)
-{
- std::string error_string;
-
- switch (reason)
- {
- case TTS_ERROR_NONE:
- {
- break;
- }
- case TTS_ERROR_OUT_OF_MEMORY:
- {
- error_string = "TTS: Out of Memory\n";
- break;
- }
- case TTS_ERROR_IO_ERROR:
- {
- error_string = "TTS: I/O error\n";
- break;
- }
- case TTS_ERROR_INVALID_PARAMETER:
- {
- error_string = "TTS: Invalid parameter\n";
- break;
- }
- case TTS_ERROR_OUT_OF_NETWORK:
- {
- error_string = "TTS: Out of network\n";
- break;
- }
- case TTS_ERROR_INVALID_STATE:
- {
- error_string = "TTS: Invalid state\n";
- break;
- }
- case TTS_ERROR_INVALID_VOICE:
- {
- error_string = "TTS: Invalid voice\n";
- break;
- }
- case TTS_ERROR_ENGINE_NOT_FOUND:
- {
- error_string = "TTS: No available engine\n";
- break;
- }
- case TTS_ERROR_TIMED_OUT:
- {
- error_string = "TTS: No answer from the daemon\n";
- break;
- }
- case TTS_ERROR_OPERATION_FAILED:
- {
- error_string = "TTS: Operation failed\n";
- break;
- }
- default:
- {
- error_string = "Invalid TTS error code\n";
- break;
- }
- }
-
- if(reason != TTS_ERROR_NONE)
- {
- DALI_LOG_WARNING("[%s:%d] tts error : %s\n", __FUNCTION__, __LINE__, error_string.c_str());
- }
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_TTS_PLAYER_H__
-#define __DALI_INTERNAL_TTS_PLAYER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <tts.h>
-#include <string>
-
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/adaptor-framework/common/tts-player.h>
-
-// INTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Text-to-speech player
- */
-class TtsPlayer : public Dali::BaseObject
-{
-
-public:
-
- /**
- * Create a TtsPlayer with the given mode.
- * This should only be called once by the Adaptor class for each given mode.
- * @param mode the mode of tts-player
- * @return A newly created TtsPlayer.
- */
- static Dali::TtsPlayer New(Dali::TtsPlayer::Mode mode);
-
- /**
- * @copydoc TtsPlayer::Play()
- */
- void Play(const std::string& text);
-
- /**
- * @copydoc TtsPlayer::Stop()
- */
- void Stop();
-
- /**
- * @copydoc TtsPlayer::Pause()
- */
- void Pause();
-
- /**
- * @copydoc TtsPlayer::Resume()
- */
- void Resume();
-
-private:
-
- /**
- * Private Constructor; see also TtsPlayer::New()
- * @param mode the mode of tts-player
- */
- TtsPlayer(Dali::TtsPlayer::Mode mode);
-
- /**
- * Destructor
- */
- virtual ~TtsPlayer();
-
- /**
- * Initializes the player.
- */
- void Initialize();
-
- /**
- * Logs the error code.
- * @param[in] reason The error code
- */
- void LogErrorCode(tts_error_e reason);
-
- /**
- * Called when the state of TTS is changed.
- *
- * @param[in] tts The handle for TTS
- * @param[in] previous A previous state
- * @param[in] current A current state
- * @param[in] userData The user data passed from the callback registration function.
- */
- static void StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void *userData);
-
- // Undefined
- TtsPlayer(const TtsPlayer&);
-
- // Undefined
- TtsPlayer& operator=(TtsPlayer&);
-
-private:
-
- bool mInitialized; ///< Whether the TTS player is initialised successfully or not
- std::string mUnplayedString; ///< The text that can not be played because tts engine is not yet initialized
- tts_h mTtsHandle; ///< The handle of TTS
- int mUtteranceId; ///< The utterance ID
-
- Dali::TtsPlayer::Mode mTtsMode; ///< The current mode of tts engine
-
-#if defined(DEBUG_ENABLED)
-public:
- static Debug::Filter* gLogFilter;
-#endif
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-// Helpers for public-api forwarding methods
-
-inline Internal::Adaptor::TtsPlayer& GetImplementation(Dali::TtsPlayer& player)
-{
- DALI_ASSERT_ALWAYS( player && "TtsPlayer handle is empty" );
-
- BaseObject& handle = player.GetBaseObject();
-
- return static_cast<Internal::Adaptor::TtsPlayer&>(handle);
-}
-
-inline const Internal::Adaptor::TtsPlayer& GetImplementation(const Dali::TtsPlayer& player)
-{
- DALI_ASSERT_ALWAYS( player && "TtsPlayer handle is empty" );
-
- const BaseObject& handle = player.GetBaseObject();
-
- return static_cast<const Internal::Adaptor::TtsPlayer&>(handle);
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_TTS_PLAYER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "virtual-keyboard-impl.h"
-
-// EXTERNAL INCLUDES
-#include <X11/Xlib.h>
-#include <Ecore_X.h>
-#include <algorithm>
-
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/adaptor-framework/common/adaptor.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/locale-utils.h>
-#include <internal/common/imf-manager-impl.h>
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace VirtualKeyboard
-{
-
-namespace
-{
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_VIRTUAL_KEYBOARD");
-#endif
-
-//forward declarations
-void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value );
-void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value );
-
-// Signals
-Dali::VirtualKeyboard::StatusSignalV2 gKeyboardStatusSignalV2;
-Dali::VirtualKeyboard::VoidSignalV2 gKeyboardResizeSignalV2;
-Dali::VirtualKeyboard::VoidSignalV2 gKeyboardLanguageChangedSignalV2;
-
-Dali::VirtualKeyboard::ReturnKeyType gReturnKeyType = Dali::VirtualKeyboard::DEFAULT; // the currently used return key type.
-
-void InputPanelStateChangeCallback( void* data, Ecore_IMF_Context* context, int value )
-{
- switch (value)
- {
- case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_SHOW\n" );
-
- gKeyboardStatusSignalV2.Emit( true );
-
- break;
- }
-
- case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_HIDE\n" );
-
- gKeyboardStatusSignalV2.Emit( false );
-
- break;
- }
-
- case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
- default:
- {
- // Do nothing
- break;
- }
- }
-}
-
-void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value )
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB InputPanelLanguageChangeCallback" );
-
- // Emit the signal that the language has changed
- gKeyboardLanguageChangedSignalV2.Emit();
-}
-
-void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value )
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB InputPanelGeometryChangedCallback\n" );
-
- // Emit signal that the keyboard is resized
- gKeyboardResizeSignalV2.Emit();
-}
-
-} // unnamed namespace
-
-void ConnectCallbacks( Ecore_IMF_Context *imfContext )
-{
- if( imfContext )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ConnectPanelCallbacks\n" );
-
- ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, NULL );
- ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, NULL );
- ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback, NULL );
- }
-}
-
-void DisconnectCallbacks( Ecore_IMF_Context *imfContext )
-{
- if( imfContext )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB DisconnectPanelCallbacks\n" );
-
- ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback );
- ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback );
- ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback );
- }
-}
-
-void Show()
-{
- if( Dali::Adaptor::IsAvailable() )
- {
- Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
-
- if( imfContext )
- {
- ecore_imf_context_input_panel_show( imfContext );
- }
- }
-}
-
-void Hide()
-{
- if( Dali::Adaptor::IsAvailable() )
- {
- Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
-
- if( imfContext )
- {
- ecore_imf_context_input_panel_hide( imfContext );
- }
- }
-}
-
-bool IsVisible()
-{
- if( Dali::Adaptor::IsAvailable() )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "IsVisible\n" );
-
- Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
-
- if ( imfContext )
- {
- if (ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_SHOW ||
- ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW)
- {
- return true;
- }
- }
- }
-
- return false;
-}
-
-void SetReturnKeyType( Dali::VirtualKeyboard::ReturnKeyType type )
-{
- if ( Dali::Adaptor::IsAvailable() )
- {
- Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
-
- if( imfContext )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB Retrun key type is changed[%d]\n", type );
-
- gReturnKeyType = type;
- ecore_imf_context_input_panel_return_key_type_set( imfContext, static_cast<Ecore_IMF_Input_Panel_Return_Key_Type>( type ) );
- }
- }
-}
-
-Dali::VirtualKeyboard::ReturnKeyType GetReturnKeyType()
-{
- return gReturnKeyType;
-}
-
-void EnablePrediction(const bool enable)
-{
- if ( Dali::Adaptor::IsAvailable() )
- {
- Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
-
- if ( imfContext )
- {
- ecore_imf_context_prediction_allow_set( imfContext, (enable)? EINA_TRUE : EINA_FALSE);
- }
- }
-}
-
-bool IsPredictionEnabled()
-{
- if ( Dali::Adaptor::IsAvailable() )
- {
- Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
-
- if ( imfContext )
- {
- // predictive text is enabled.
- if ( ecore_imf_context_input_panel_enabled_get( imfContext ) == EINA_TRUE )
- {
- return true;
- }
- }
- }
-
- return false;
-}
-
-Rect<int> GetSizeAndPosition()
-{
- int xPos, yPos, width, height;
-
- width = height = xPos = yPos = 0;
- if ( Dali::Adaptor::IsAvailable() )
- {
- Dali::ImfManager imfManager = ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
-
- if( imfContext )
- {
- ecore_imf_context_input_panel_geometry_get(imfContext, &xPos, &yPos, &width, &height);
- }
- else
- {
- DALI_LOG_WARNING("VKB Unable to get IMF Context so GetSize unavailable\n");
- // return 0 as real size unknown.
- }
- }
-
- return Rect<int>(xPos,yPos,width,height);
-}
-
-void RotateTo(int angle)
-{
- // Get focus window used by Keyboard and rotate it
- Display* display = XOpenDisplay(0);
- if (display)
- {
- ::Window focusWindow;
- int revert;
- // Get Focus window
- XGetInputFocus(display, &focusWindow, &revert);
-
- ecore_x_window_prop_property_set(focusWindow,
- ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
- ECORE_X_ATOM_CARDINAL, 32, &angle, 1);
- XCloseDisplay(display);
- }
-}
-
-Dali::VirtualKeyboard::StatusSignalV2& StatusChangedSignal()
-{
- return gKeyboardStatusSignalV2;
-}
-
-Dali::VirtualKeyboard::VoidSignalV2& ResizedSignal()
-{
- return gKeyboardResizeSignalV2;
-}
-
-Dali::VirtualKeyboard::VoidSignalV2& LanguageChangedSignal()
-{
- return gKeyboardLanguageChangedSignalV2;
-}
-
-Dali::VirtualKeyboard::TextDirection GetTextDirection()
-{
- Dali::VirtualKeyboard::TextDirection direction ( Dali::VirtualKeyboard::LeftToRight );
-
- if ( Dali::Adaptor::IsAvailable() )
- {
- Dali::ImfManager imfManager = ImfManager::Get();
-
- if ( imfManager )
- {
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
-
- if ( imfContext )
- {
- char* locale( NULL );
- ecore_imf_context_input_panel_language_locale_get( imfContext, &locale );
-
- if ( locale )
- {
- direction = Locale::GetTextDirection( std::string( locale ) );
- free( locale );
- }
- }
- }
- }
- return direction;
-}
-
-} // namespace VirtualKeyboard
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_VIRTUAL_KEYBOARD_H__
-#define __DALI_INTERNAL_VIRTUAL_KEYBOARD_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <Ecore_IMF.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/common/virtual-keyboard.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Implementation of the virtual keyboard namespace
- */
-namespace VirtualKeyboard
-{
-
-/**
- * Connect the virtual keyboard callbacks.
- * To get the virtual keyboard callbacks then you have to connect these callback.
- * If you don't connect callbacks, you can't get virtual keyboard signals.
- * The signals are StatusChangedSignal, ResizedSignal and LanguageChangedSignal.
- */
-void ConnectCallbacks( Ecore_IMF_Context *imfContext );
-
-/**
- * Disconnect the virtual keyboard callbacks.
- * The signals are StatusChangedSignal, ResizedSignal and LanguageChangedSignal.
- */
-void DisconnectCallbacks( Ecore_IMF_Context *imfContext );
-
-/**
- * @copydoc Dali::VirtualKeyboard::Show()
- */
-void Show();
-
-/**
- * @copydoc Dali::VirtualKeyboard::Hide()
- */
-void Hide();
-
-/**
- * @copydoc Dali::VirtualKeyboard::IsVisible()
- */
-bool IsVisible();
-
-/**
- * @copydoc Dali::VirtualKeyboard::SetReturnKeyType()
- */
-void SetReturnKeyType( Dali::VirtualKeyboard::ReturnKeyType type );
-
-/**
- * @copydoc Dali::VirtualKeyboard::GetReturnKeyType()
- */
-Dali::VirtualKeyboard::ReturnKeyType GetReturnKeyType();
-
-/**
- * @copydoc Dali::VirtualKeyboard::EnablePrediction()
- */
-void EnablePrediction(const bool enable);
-
-/**
- * @copydoc Dali::VirtualKeyboard::IsPredictionEnabled()
- */
-bool IsPredictionEnabled();
-
-/**
- * @copydoc Dali::VirtualKeyboard::GetSizeAndPosition()
- */
-Rect<int> GetSizeAndPosition();
-
-/**
- * @copydoc Dali::VirtualKeyboard::RotateKeyboard()
- */
-void RotateTo(int angle);
-
-/**
- * @copydox Dali::VirtualKeyboard::StatusChangedSignal()
- */
-Dali::VirtualKeyboard::StatusSignalV2& StatusChangedSignal();
-
-/**
- * @copydox Dali::VirtualKeyboard::ResizedSignal()
- */
-Dali::VirtualKeyboard::VoidSignalV2& ResizedSignal();
-
-/**
- * @copydox Dali::VirtualKeyboard::LanguageChangedSignal()
- */
-Dali::VirtualKeyboard::VoidSignalV2& LanguageChangedSignal();
-
-/**
- * @copydoc Dali::VirtualKeyboard::GetTextDirection
- */
-Dali::VirtualKeyboard::TextDirection GetTextDirection();
-
-} // namespace VirtualKeyboard
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_VIRTUAL_KEYBOARD_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <vconf.h>
-#include <vconf-keys.h>
-
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include "vsync-monitor.h"
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VSYNC_MONITOR");
-#endif
-
-const char * const DRM_DEVICE( "/dev/dri/card0" );
-const int FD_NONE( -1 );
-
-void ScreenStatusChanged(keynode_t* node, void* data)
-{
- VSyncMonitor* vsyncMonitor( static_cast< VSyncMonitor* >( data ) );
-
- int status = 0;
- vconf_get_int( VCONFKEY_PM_STATE, &status );
-
- // status values
- // - VCONFKEY_PM_STATE_NORMAL : turn vsync on
- // - VCONFKEY_PM_STATE_LCDDIM : turn vsync off
- // - VCONFKEY_PM_STATE_LCDOFF : turn vsync off
- // - VCONFKEY_PM_STATE_SLEEP : turn vsync off
- const bool screenOn( VCONFKEY_PM_STATE_NORMAL == status );
-
- vsyncMonitor->SetUseHardware( screenOn );
-
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "%s, Screen %s.\n", __PRETTY_FUNCTION__, screenOn ? "On" : "Off" );
-}
-
-} // unnamed namespace
-
-VSyncMonitor::VSyncMonitor()
-: mFileDescriptor( FD_NONE ),
- mUseHardware( true )
-{
- vconf_notify_key_changed( VCONFKEY_PM_STATE, ScreenStatusChanged, this );
-}
-
-VSyncMonitor::~VSyncMonitor()
-{
- Terminate();
-
- vconf_ignore_key_changed( VCONFKEY_PM_STATE, ScreenStatusChanged );
-}
-
-void VSyncMonitor::SetUseHardware( bool useHardware )
-{
- mUseHardware = useHardware;
-}
-
-void VSyncMonitor::Initialize()
-{
- DALI_ASSERT_DEBUG( mFileDescriptor == FD_NONE && "VSyncMonitor::Initialize() called twice" );
-
- // Read initial 'use hardware' status
- ScreenStatusChanged( NULL, this );
-
- // open /dev node
- mFileDescriptor = open( DRM_DEVICE, O_RDWR );
-
- // setup vblank request - block and wait for next vblank
- mVBlankInfo.request.type = DRM_VBLANK_NEXTONMISS;
- mVBlankInfo.request.sequence = 0;
- mVBlankInfo.request.signal = 0;
-
- // setup vblank reply - block and wait for next vblank
- mVBlankInfo.reply.type = DRM_VBLANK_NEXTONMISS;
- mVBlankInfo.reply.sequence = 0;
- mVBlankInfo.reply.tval_sec = 0;
- mVBlankInfo.reply.tval_usec = 0;
-}
-
-void VSyncMonitor::Terminate()
-{
- if( mFileDescriptor != FD_NONE )
- {
- close( mFileDescriptor );
- mFileDescriptor = FD_NONE;
- }
-}
-
-bool VSyncMonitor::UseHardware()
-{
- return mUseHardware && (FD_NONE != mFileDescriptor );
-}
-
-
-bool VSyncMonitor::DoSync( unsigned int& frameNumber, unsigned int& seconds, unsigned int& microseconds )
-{
- DALI_ASSERT_DEBUG( mFileDescriptor != FD_NONE && "ECoreX::VSyncMonitor is not initialized" );
-
- if( 0 == drmWaitVBlank( mFileDescriptor, &mVBlankInfo ) )
- {
- frameNumber = mVBlankInfo.reply.sequence;
- seconds = mVBlankInfo.reply.tval_sec;
- microseconds = mVBlankInfo.reply.tval_usec;
-
- return true;
- }
-
- return false;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_VSYNC_MONITOR_IMPL_H__
-#define __DALI_INTERNAL_VSYNC_MONITOR_IMPL_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <xf86drm.h>
-
-// INTERNAL INCLUDES
-#include <base/interfaces/vsync-monitor-interface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * Tizen interface for monitoring VSync
- */
-class VSyncMonitor : public VSyncMonitorInterface
-{
-public:
- /**
- * Default constructor
- */
- VSyncMonitor();
-
- /**
- * Destructor
- */
- virtual ~VSyncMonitor();
-
-public:
-
- /**
- * Set the use hardware flag
- * @param[in] useHardware The new state for the use hardware flag.
- */
- void SetUseHardware( bool useHardware );
-
-private: // From Dali::Internal::Adaptor::VSyncMonitorInterface
-
- /**
- * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::Initialize
- */
- virtual void Initialize();
-
- /**
- * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::Terminate
- */
- virtual void Terminate();
-
- /**
- * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::UseHardware
- */
- virtual bool UseHardware();
-
- /**
- * copydoc Dali::Internal::Adaptor::VSyncMonitorInterface::DoSync
- */
- virtual bool DoSync( unsigned int& frameNumber, unsigned int& seconds, unsigned int& microseconds );
-
-private:
-
- int mFileDescriptor; ///< DRM dev node file descriptor
- drmVBlank mVBlankInfo;
- bool mUseHardware; ///< Hardware VSyncs available flag
-
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_VSYNC_MONITOR_IMPL_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "window-impl.h"
-
-// EXTERNAL HEADERS
-#include <Ecore.h>
-#include <Ecore_X.h>
-
-#include <dali/integration-api/core.h>
-#include <dali/integration-api/system-overlay.h>
-#include <dali/public-api/render-tasks/render-task.h>
-#include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/public-api/adaptor-framework/common/orientation.h>
-
-// INTERNAL HEADERS
-#include <internal/common/ecore-x/window-render-surface.h>
-#include <internal/common/drag-and-drop-detector-impl.h>
-#include <internal/common/indicator-impl.h>
-#include <internal/common/window-visibility-observer.h>
-#include <internal/common/orientation-impl.h>
-
-namespace
-{
-const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
-const float INDICATOR_SHOW_Y_POSITION( 0.0f );
-const float INDICATOR_HIDE_Y_POSITION( -52.0f );
-}
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_WINDOW");
-#endif
-
-/**
- * TODO: Abstract Window class out and move this into a window implementation for Ecore
- */
-struct Window::EventHandler
-{
- /**
- * Constructor
- * @param[in] window A pointer to the window class.
- */
- EventHandler( Window* window )
- : mWindow( window ),
- mWindowPropertyHandler( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_PROPERTY, EcoreEventWindowPropertyChanged, this ) ),
- mClientMessagehandler( ecore_event_handler_add( ECORE_X_EVENT_CLIENT_MESSAGE, EcoreEventClientMessage, this ) ),
- mEcoreWindow( 0 )
- {
- // store ecore window handle
- ECoreX::WindowRenderSurface* x11Window( dynamic_cast< ECoreX::WindowRenderSurface * >( mWindow->mSurface ) );
- if( x11Window )
- {
- mEcoreWindow = x11Window->GetXWindow();
- }
- DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no ecore x window");
-
- // set property on window to get deiconify approve client message
- unsigned int tmp = 1;
- ecore_x_window_prop_card32_set(mEcoreWindow,
- ECORE_X_ATOM_E_DEICONIFY_APPROVE,
- &tmp, 1);
- }
-
- /**
- * Destructor
- */
- ~EventHandler()
- {
- if ( mWindowPropertyHandler )
- {
- ecore_event_handler_del( mWindowPropertyHandler );
- }
- if ( mClientMessagehandler )
- {
- ecore_event_handler_del( mClientMessagehandler );
- }
- }
-
- // Static methods
-
- /// Called when the window properties are changed.
- static Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
- {
- Ecore_X_Event_Window_Property* propertyChangedEvent( (Ecore_X_Event_Window_Property*)event );
- EventHandler* handler( (EventHandler*)data );
- Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
-
- if ( handler && handler->mWindow )
- {
- WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
- if ( observer && ( propertyChangedEvent->win == handler->mEcoreWindow ) )
- {
- Ecore_X_Window_State_Hint state( ecore_x_icccm_state_get( propertyChangedEvent->win ) );
-
- switch ( state )
- {
- case ECORE_X_WINDOW_STATE_HINT_WITHDRAWN:
- {
- // Window was hidden.
- observer->OnWindowHidden();
- DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Withdrawn\n", handler->mEcoreWindow );
- handled = ECORE_CALLBACK_DONE;
- }
- break;
-
- case ECORE_X_WINDOW_STATE_HINT_ICONIC:
- {
- // Window was iconified (minimised).
- observer->OnWindowHidden();
- DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Iconfied\n", handler->mEcoreWindow );
- handled = ECORE_CALLBACK_DONE;
- }
- break;
-
- case ECORE_X_WINDOW_STATE_HINT_NORMAL:
- {
- // Window was shown.
- observer->OnWindowShown();
- DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Shown\n", handler->mEcoreWindow );
- handled = ECORE_CALLBACK_DONE;
- }
- break;
-
- default:
- // Ignore
- break;
- }
- }
- }
-
- return handled;
- }
-
- /// Called when the window properties are changed.
- static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
- {
- Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
- Ecore_X_Event_Client_Message* clientMessageEvent( (Ecore_X_Event_Client_Message*)event );
- EventHandler* handler( (EventHandler*)data );
-
- if (clientMessageEvent->message_type == ECORE_X_ATOM_E_DEICONIFY_APPROVE)
- {
- ECoreX::WindowRenderSurface* x11Window( dynamic_cast< ECoreX::WindowRenderSurface * >( handler->mWindow->mSurface ) );
- WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
-
- if ( observer && ( (unsigned int)clientMessageEvent->data.l[0] == handler->mEcoreWindow ) )
- {
- if (clientMessageEvent->data.l[1] == 0) //wm sends request message using value 0
- {
- observer->OnWindowShown();
-
- // request to approve the deiconify. render-surface should send proper event after real rendering
- if(x11Window)
- {
- x11Window->RequestToApproveDeiconify();
- }
-
- handled = ECORE_CALLBACK_DONE;
- }
- }
- }
-
- return handled;
- }
-
- // Data
- Window* mWindow;
- Ecore_Event_Handler* mWindowPropertyHandler;
- Ecore_Event_Handler* mClientMessagehandler;
- Ecore_X_Window mEcoreWindow;
-};
-
-
-Window* Window::New(const PositionSize& posSize, const std::string& name, bool isTransparent)
-{
- Window* window = new Window();
- window->mIsTransparent = isTransparent;
- window->Initialize(posSize, name);
- return window;
-}
-
-void Window::SetAdaptor(Dali::Adaptor& adaptor)
-{
- DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
- mStarted = true;
-
- // Only create one overlay per window
- Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
- Integration::Core& core = adaptorImpl.GetCore();
- mOverlay = &core.GetSystemOverlay();
-
- Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
- taskList.CreateTask();
-
- mAdaptor = &adaptorImpl;
- mAdaptor->AddObserver( *this );
-
- // Can only create the detector when we know the Core has been instantiated.
- mDragAndDropDetector = DragAndDropDetector::New();
- mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
-
- if( mOrientation )
- {
- mOrientation->SetAdaptor(adaptor);
- }
-
- if( mIndicator != NULL )
- {
- mIndicator->SetAdaptor(mAdaptor);
- }
-}
-
-RenderSurface* Window::GetSurface()
-{
- return mSurface;
-}
-
-void Window::SetIndicatorStyle( Dali::Window::IndicatorStyle style )
-{
- mIndicatorStyle = style;
-}
-
-void Window::ShowIndicator( bool show )
-{
- DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "%s\n", show?"SHOW":"HIDE" );
- DALI_ASSERT_DEBUG(mOverlay);
-
- if(show)
- {
- mIndicatorVisible = Dali::Window::VISIBLE;
- }
- else
- {
- mIndicatorVisible = Dali::Window::INVISIBLE;
- }
-
- DoShowIndicator( mIndicatorOrientation );
-}
-
-void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
-{
- DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
- DALI_ASSERT_DEBUG(mOverlay);
-
- ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
- DALI_ASSERT_DEBUG(x11Window);
- Ecore_X_Window xWinId = x11Window->GetXWindow();
-
- mIndicatorVisible = visibleMode;
-
- if ( mIndicatorVisible == Dali::Window::VISIBLE )
- {
- // when the indicator is visible, set proper mode for indicator server according to bg mode
- if ( mIndicatorOpacityMode == Dali::Window::OPAQUE )
- {
- ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_OPAQUE);
- }
- else if ( mIndicatorOpacityMode == Dali::Window::TRANSLUCENT )
- {
- ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
- }
-#if defined(DALI_PROFILE_MOBILE)
- else if ( mIndicatorOpacityMode == Dali::Window::TRANSPARENT )
- {
- ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_BG_TRANSPARENT);
- }
-#endif
- }
- else
- {
- // when the indicator is not visible, set TRANSPARENT mode for indicator server
- ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_TRANSPARENT); // it means hidden indicator
- }
-
- DoShowIndicator( mIndicatorOrientation );
-}
-
-void Window::RotateIndicator(Dali::Window::WindowOrientation orientation)
-{
- DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
-
- DoRotateIndicator( orientation );
-}
-
-void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
-{
- mIndicatorOpacityMode = opacityMode;
-
- if( mIndicator != NULL )
- {
- mIndicator->SetOpacityMode( opacityMode );
- }
-}
-
-void Window::SetClass(std::string name, std::string klass)
-{
- // Get render surface's x11 window
- if( mSurface )
- {
- ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
- if( x11Window )
- {
- ecore_x_icccm_name_class_set( x11Window->GetXWindow(), name.c_str(), klass.c_str() );
- }
- }
-}
-
-Window::Window()
-: mSurface(NULL),
- mIndicatorStyle(Dali::Window::CHANGEABLE_COLOR),
- mIndicatorVisible(Dali::Window::VISIBLE),
- mIndicatorIsShown(false),
- mShowRotatedIndicatorOnClose(false),
- mStarted(false),
- mIsTransparent(false),
- mWMRotationAppSet(false),
- mIndicator(NULL),
- mIndicatorOrientation(Dali::Window::PORTRAIT),
- mNextIndicatorOrientation(Dali::Window::PORTRAIT),
- mIndicatorOpacityMode(Dali::Window::OPAQUE),
- mOverlay(NULL),
- mAdaptor(NULL)
-{
-}
-
-Window::~Window()
-{
- delete mEventHandler;
-
- if ( mAdaptor )
- {
- mAdaptor->RemoveObserver( *this );
- mAdaptor->SetDragAndDropDetector( NULL );
- mAdaptor = NULL;
- }
-
- delete mSurface;
-}
-
-void Window::Initialize(const PositionSize& windowPosition, const std::string& name)
-{
- // create an X11 window by default
- Any surface;
- Any display;
- mSurface = new ECoreX::WindowRenderSurface( windowPosition, surface, display, name, mIsTransparent );
- mOrientation = Orientation::New(this);
-
- // create event handler for X11 window
- mEventHandler = new EventHandler( this );
-}
-
-void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
-{
- if( mIndicator == NULL )
- {
- if( mIndicatorVisible != Dali::Window::INVISIBLE )
- {
- mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, mIndicatorStyle, this );
- mIndicator->SetOpacityMode( mIndicatorOpacityMode );
- Dali::Actor actor = mIndicator->GetActor();
- SetIndicatorActorRotation();
- mOverlay->Add(actor);
- }
- // else don't create a hidden indicator
- }
- else // Already have indicator
- {
- if( mIndicatorVisible == Dali::Window::VISIBLE )
- {
- // If we are resuming, and rotation has changed,
- if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
- {
- // then close current indicator and open new one
- mShowRotatedIndicatorOnClose = true;
- mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
- // Don't show actor - will contain indicator for old orientation.
- }
- }
- }
-
- // set indicator visible mode
- if( mIndicator != NULL )
- {
- mIndicator->SetVisible( mIndicatorVisible );
- }
-
- bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
- SetIndicatorProperties( show, lastOrientation );
- mIndicatorIsShown = show;
-}
-
-void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
-{
- if( mIndicatorIsShown )
- {
- mShowRotatedIndicatorOnClose = true;
- mNextIndicatorOrientation = orientation;
- mIndicator->Close(); // May synchronously call IndicatorClosed() callback
- }
- else
- {
- // Save orientation for when the indicator is next shown
- mShowRotatedIndicatorOnClose = false;
- mNextIndicatorOrientation = orientation;
- }
-}
-
-void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
-{
- ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
- if( x11Window )
- {
- Ecore_X_Window win = x11Window->GetXWindow();
-
- int show_state = static_cast<int>( isShow );
- ecore_x_window_prop_property_set( win,
- ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE,
- ECORE_X_ATOM_CARDINAL, 32, &show_state, 1);
-
- if ( isShow )
- {
- ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_ON);
- }
- else
- {
- ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
- }
- }
-}
-
-void Window::IndicatorTypeChanged(Indicator::Type type)
-{
- ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
- if( x11Window )
- {
- Ecore_X_Window win = x11Window->GetXWindow();
- switch(type)
- {
- case Indicator::INDICATOR_TYPE_1:
- ecore_x_e_illume_indicator_type_set( win, ECORE_X_ILLUME_INDICATOR_TYPE_1 );
- break;
-
- case Indicator::INDICATOR_TYPE_2:
- ecore_x_e_illume_indicator_type_set( win, ECORE_X_ILLUME_INDICATOR_TYPE_2 );
- break;
-
- case Indicator::INDICATOR_TYPE_UNKNOWN:
- default:
- break;
- }
- }
-}
-
-void Window::IndicatorClosed( Indicator* indicator )
-{
- DALI_LOG_TRACE_METHOD( gWindowLogFilter );
-
- if( mShowRotatedIndicatorOnClose )
- {
- Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
- mIndicator->Open(mNextIndicatorOrientation);
- mIndicatorOrientation = mNextIndicatorOrientation;
- SetIndicatorActorRotation();
- DoShowIndicator(currentOrientation);
- }
-}
-
-void Window::SetIndicatorActorRotation()
-{
- DALI_LOG_TRACE_METHOD( gWindowLogFilter );
- DALI_ASSERT_DEBUG( mIndicator != NULL );
-
- Dali::Actor actor = mIndicator->GetActor();
- switch( mIndicatorOrientation )
- {
- case Dali::Window::PORTRAIT:
- actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
- actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- actor.SetRotation( Degree(0), Vector3::ZAXIS );
- break;
- case Dali::Window::PORTRAIT_INVERSE:
- actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
- actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- actor.SetRotation( Degree(180), Vector3::ZAXIS );
- break;
- case Dali::Window::LANDSCAPE:
- actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
- actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- actor.SetRotation( Degree(270), Vector3::ZAXIS );
- break;
- case Dali::Window::LANDSCAPE_INVERSE:
- actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
- actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- actor.SetRotation( Degree(90), Vector3::ZAXIS );
- break;
- }
-}
-
-void Window::Raise()
-{
- ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
- if( x11Window )
- {
- Ecore_X_Window win = x11Window->GetXWindow();
- ecore_x_window_raise(win);
- }
-}
-
-void Window::Lower()
-{
- ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
- if( x11Window )
- {
- Ecore_X_Window win = x11Window->GetXWindow();
- ecore_x_window_lower(win);
- }
-}
-
-void Window::Activate()
-{
- ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
- if( x11Window )
- {
- Ecore_X_Window win = x11Window->GetXWindow();
- ecore_x_netwm_client_active_request(ecore_x_window_root_get(win), win, 1 /* request type, 1:application, 2:pager */, 0);
- }
-}
-
-Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
-{
- return mDragAndDropDetector;
-}
-
-void Window::OnStart()
-{
- DoShowIndicator( mIndicatorOrientation );
-}
-
-void Window::OnPause()
-{
-}
-
-void Window::OnResume()
-{
- // resume indicator status
- if( mIndicator != NULL )
- {
- // Restore own indicator opacity
- // Send opacity mode to indicator service when app resumed
- mIndicator->SetOpacityMode( mIndicatorOpacityMode );
- }
-}
-
-void Window::OnStop()
-{
- if( mIndicator )
- {
- mIndicator->Close();
- }
-
- delete mIndicator;
- mIndicator = NULL;
-}
-
-void Window::OnDestroy()
-{
- mAdaptor = NULL;
-}
-
-OrientationPtr Window::GetOrientation()
-{
- return mOrientation;
-}
-
-void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
-{
- bool found = false;
-
- for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
- {
- if(mAvailableOrientations[i] == orientation)
- {
- found = true;
- break;
- }
- }
-
- if( ! found )
- {
- mAvailableOrientations.push_back(orientation);
- SetAvailableOrientations( mAvailableOrientations );
- }
-}
-
-void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
-{
- for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
- iter != mAvailableOrientations.end(); ++iter )
- {
- if( *iter == orientation )
- {
- mAvailableOrientations.erase( iter );
- break;
- }
- }
- SetAvailableOrientations( mAvailableOrientations );
-}
-
-void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
-{
- DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
-
- mAvailableOrientations = orientations;
- ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
- if( x11Window )
- {
- Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
- if( ! mWMRotationAppSet )
- {
- mWMRotationAppSet = true;
- ecore_x_e_window_rotation_app_set(ecoreWindow, EINA_TRUE);
- }
-
- int rotations[4];
- for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
- {
- rotations[i] = static_cast<int>(mAvailableOrientations[i]);
- }
- ecore_x_e_window_rotation_available_rotations_set(ecoreWindow, rotations, mAvailableOrientations.size() );
-
- }
-}
-
-const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
-{
- return mAvailableOrientations;
-}
-
-void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
-{
- mPreferredOrientation = orientation;
-
- ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
- if( x11Window )
- {
- Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
-
- if( ! mWMRotationAppSet )
- {
- mWMRotationAppSet = true;
- ecore_x_e_window_rotation_app_set(ecoreWindow, EINA_TRUE);
- }
-
- ecore_x_e_window_rotation_preferred_rotation_set(ecoreWindow, orientation);
- }
-}
-
-Dali::Window::WindowOrientation Window::GetPreferredOrientation()
-{
- return mPreferredOrientation;
-}
-
-void Window::RotationDone( int orientation, int width, int height )
-{
- // Tell window manager we're done
- ECoreX::WindowRenderSurface* x11Window = dynamic_cast< ECoreX::WindowRenderSurface * >( mSurface );
- if( x11Window )
- {
- Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
- Ecore_X_Window root = ecore_x_window_root_get(ecoreWindow);
-
- /**
- * send rotation done message to wm, even if window is already rotated.
- * that's why wm must be wait for comming rotation done message
- * after sending rotation request.
- */
- ecore_x_e_window_rotation_change_done_send(root, ecoreWindow, orientation, width, height);
-
- /**
- * set rotate window property
- */
- int angles[2] = { orientation, orientation };
- ecore_x_window_prop_property_set( ecoreWindow,
- ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
- ECORE_X_ATOM_CARDINAL, 32, &angles, 2 );
- }
-}
-
-
-} // Adaptor
-} // Internal
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_WINDOW_H__
-#define __DALI_INTERNAL_WINDOW_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/adaptor-framework/common/window.h>
-#include <dali/public-api/adaptor-framework/common/orientation.h>
-#include <dali/public-api/adaptor-framework/common/render-surface.h>
-#include <dali/public-api/adaptor-framework/common/drag-and-drop-detector.h>
-
-// INTERNAL INCLUDES
-#include <base/lifecycle-observer.h>
-#include <internal/common/adaptor-impl.h>
-#include <internal/common/indicator-impl.h>
-
-
-namespace Dali
-{
-class Adaptor;
-
-namespace Integration
-{
-class SystemOverlay;
-}
-
-namespace Internal
-{
-namespace Adaptor
-{
-class RenderSurface;
-class Indicator;
-class Orientation;
-
-class Window;
-typedef IntrusivePtr<Window> WindowPtr;
-typedef IntrusivePtr<Orientation> OrientationPtr;
-
-/**
- * Window provides a surface to render onto with orientation & indicator properties.
- */
-class Window : public Dali::BaseObject, public Indicator::Observer, public LifeCycleObserver
-{
-public:
- /**
- * Create a new Window. This should only be called once by the Application class
- * @param[in] windowPosition The position and size of the window
- * @param[in] name The window title
- * @param[in] isTransparent Whether window is transparent
- * @return A newly allocated Window
- */
- static Window* New(const PositionSize& posSize, const std::string& name, bool isTransparent = false);
-
- /**
- * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
- * @param[in] adaptor An initialized adaptor
- */
- void SetAdaptor(Dali::Adaptor& adaptor);
-
- /**
- * Get the window surface
- * @return The render surface
- */
- RenderSurface* GetSurface();
-
- /**
- * @copydoc Dali::Window::SetIndicatorStyle()
- */
- void SetIndicatorStyle( Dali::Window::IndicatorStyle style );
-
- /**
- * @copydoc Dali::Window::ShowIndicator()
- */
- void ShowIndicator( bool show );
-
- /**
- * @copydoc Dali::Window::ShowIndicator()
- */
- void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
-
- /**
- * @copydoc Dali::Window::SetIndicatorBgOpacity()
- */
- void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
-
- /**
- * @copydoc Dali::Window::RotateIndicator()
- */
- void RotateIndicator( Dali::Window::WindowOrientation orientation );
-
- /**
- * @copydoc Dali::Window::SetClass()
- */
- void SetClass( std::string name, std::string klass );
-
- /**
- * @copydoc Dali::Window::Raise()
- */
- void Raise();
-
- /**
- * @copydoc Dali::Window::Lower()
- */
- void Lower();
-
- /**
- * @copydoc Dali::Window::Activate()
- */
- void Activate();
-
- /**
- * @copydoc Dali::Window::GetOrientation()
- */
- OrientationPtr GetOrientation();
-
- /**
- * @copydoc Dali::Window::AddAvailableOrientation()
- */
- void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
-
- /**
- * @copydoc Dali::Window::RemoveAvailableOrientation()
- */
- void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
-
- /**
- * @copydoc Dali::Window::SetAvailableOrientations()
- */
- void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
-
- /**
- * @copydoc Dali::Window::GetAvailableOrientations()
- */
- const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
-
- /**
- * @copydoc Dali::Window::SetPreferredOrientation()
- */
- void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
-
- /**
- * @copydoc Dali::Window::GetPreferredOrientation()
- */
- Dali::Window::WindowOrientation GetPreferredOrientation();
-
- /**
- * @copydoc Dali::Window::GetDragAndDropDetector() const
- */
- Dali::DragAndDropDetector GetDragAndDropDetector() const;
-
- /**
- * Called from Orientation after the Change signal has been sent
- */
- void RotationDone( int orientation, int width, int height );
-
-
-private:
- /**
- * Private constructor.
- * @sa Window::New()
- */
- Window();
-
- /**
- * Destructor
- */
- virtual ~Window();
-
- /**
- * Second stage initialization
- */
- void Initialize(const PositionSize& posSize, const std::string& name);
-
- /**
- * Shows / hides the indicator bar.
- * Handles close/open if rotation changes whilst hidden
- */
- void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
-
- /**
- * Close current indicator and open a connection onto the new indicator service.
- * Effect may not be synchronous if waiting for an indicator update on existing connection.
- */
- void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
-
- /**
- * Change the indicator actor's rotation to match the current orientation
- */
- void SetIndicatorActorRotation();
-
- /**
- * Set the indicator properties on the window
- */
- void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
-
-private: // Indicator::Observer interface
-
- /**
- * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorTypeChanged()
- */
- virtual void IndicatorTypeChanged( Indicator::Type type );
-
- /**
- * @copydoc Dali::Internal::Adaptor::Indicator::Observer::IndicatorClosed()
- */
- virtual void IndicatorClosed(Indicator* indicator);
-
-private: // Adaptor::Observer interface
-
- /**
- * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
- */
- virtual void OnStart();
-
- /**
- * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
- */
- virtual void OnPause();
-
- /**
- * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
- */
- virtual void OnResume();
-
- /**
- * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
- */
- virtual void OnStop();
-
- /**
- * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
- */
- virtual void OnDestroy();
-
-private:
-
- typedef std::vector<Indicator*> DiscardedIndicators;
-
- RenderSurface* mSurface;
- Dali::Window::IndicatorStyle mIndicatorStyle; ///< indicator style
- Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
- bool mIndicatorIsShown:1; ///< private state
- bool mShowRotatedIndicatorOnClose:1;
- bool mStarted:1;
- bool mIsTransparent:1;
- bool mWMRotationAppSet:1;
- Indicator* mIndicator;
- Dali::Window::WindowOrientation mIndicatorOrientation;
- Dali::Window::WindowOrientation mNextIndicatorOrientation;
- Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
- Integration::SystemOverlay* mOverlay;
- Adaptor* mAdaptor;
- Dali::DragAndDropDetector mDragAndDropDetector;
-
- struct EventHandler;
- EventHandler* mEventHandler;
-
- OrientationPtr mOrientation;
- std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
- Dali::Window::WindowOrientation mPreferredOrientation;
-};
-
-} // namespace Adaptor
-} // namepsace Internal
-
-// Helpers for public-api forwarding methods
-
-inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
-{
- DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
- BaseObject& object = window.GetBaseObject();
- return static_cast<Internal::Adaptor::Window&>(object);
-}
-
-inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
-{
- DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
- const BaseObject& object = window.GetBaseObject();
- return static_cast<const Internal::Adaptor::Window&>(object);
-}
-
-} // namespace Dali
-
-
-#endif // __DALI_INTERNAL_WINDOW_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_WINDOW_VISIBILITY_OBSERVER_H__
-#define __DALI_INTERNAL_WINDOW_VISIBILITY_OBSERVER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * An interface used to observe when the application's window is shown/hidden.
- */
-class WindowVisibilityObserver
-{
-public:
-
- /**
- * Called when the window becomes fully or partially visible.
- */
- virtual void OnWindowShown() = 0;
-
- /**
- * Called when the window is fully hidden.
- */
- virtual void OnWindowHidden() = 0;
-
-protected:
-
- /**
- * Protected Constructor.
- */
- WindowVisibilityObserver()
- {
- }
-
- /**
- * Protected virtual destructor.
- */
- virtual ~WindowVisibilityObserver()
- {
- }
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_WINDOW_VISIBILITY_OBSERVER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "framework.h"
-
-// EXTERNAL INCLUDES
-#include <X11/Xlib.h>
-#include <app.h>
-#include <bundle.h>
-#include <Ecore.h>
-#include <boost/bind.hpp>
-
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/callback-manager.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-
-/// Application Status Enum
-enum
-{
- APP_CREATE,
- APP_TERMINATE,
- APP_PAUSE,
- APP_RESUME,
- APP_RESET,
- APP_LANGUAGE_CHANGE,
-};
-
-} // Unnamed namespace
-
-/**
- * Impl to hide EFL data members
- */
-struct Framework::Impl
-{
- // Constructor
-
- Impl(void* data)
- {
- mEventCallback.create = AppCreate;
- mEventCallback.terminate = AppTerminate;
- mEventCallback.pause = AppPause;
- mEventCallback.resume = AppResume;
- mEventCallback.service = AppService;
- mEventCallback.low_memory = NULL;
- mEventCallback.low_battery = NULL;
- mEventCallback.device_orientation = DeviceRotated;
- mEventCallback.language_changed = AppLanguageChange;
- mEventCallback.region_format_changed = NULL;
-
- mCallbackManager = CallbackManager::New();
- }
-
- ~Impl()
- {
- // we're quiting the main loop so
- // mCallbackManager->RemoveAllCallBacks() does not need to be called
- // to delete our abort handler
- delete mCallbackManager;
- }
-
- // Data
-
- boost::function<void(void)> mAbortCallBack;
- app_event_callback_s mEventCallback;
- CallbackManager *mCallbackManager;
- // Static methods
-
- /**
- * Called by AppCore on application creation.
- */
- static bool AppCreate(void *data)
- {
- return static_cast<Framework*>(data)->SlpAppStatusHandler(APP_CREATE);
- }
-
- /**
- * Called by AppCore when the application should terminate.
- */
- static void AppTerminate(void *data)
- {
- static_cast<Framework*>(data)->SlpAppStatusHandler(APP_TERMINATE);
- }
-
- /**
- * Called by AppCore when the application is paused.
- */
- static void AppPause(void *data)
- {
- static_cast<Framework*>(data)->SlpAppStatusHandler(APP_PAUSE);
- }
-
- /**
- * Called by AppCore when the application is resumed.
- */
- static void AppResume(void *data)
- {
- static_cast<Framework*>(data)->SlpAppStatusHandler(APP_RESUME);
- }
-
- /**
- * Called by AppCore when the application is launched from another module (e.g. homescreen).
- * @param[in] b the bundle data which the launcher module sent
- */
- static void AppService(service_h service, void *data)
- {
- Framework* framework = static_cast<Framework*>(data);
-
- if(framework)
- {
- bundle *bundleData = NULL;
- service_to_bundle(service, &bundleData);
-
- if(bundleData)
- {
- // get bundle name
- char* bundleName = const_cast<char*>(bundle_get_val(bundleData, "name"));
- if(bundleName != NULL)
- {
- framework->SetBundleName(bundleName);
- }
-
- // get bundle id
- char* bundleId = const_cast<char*>(bundle_get_val(bundleData, "id"));
- if(bundleId != NULL)
- {
- framework->SetBundleId(bundleId);
- }
- }
- framework->SlpAppStatusHandler(APP_RESET);
- }
- }
-
- /**
- * Called by AppCore when the language changes on the device.
- */
- static void AppLanguageChange(void* data)
- {
- static_cast<Framework*>(data)->SlpAppStatusHandler(APP_LANGUAGE_CHANGE);
- }
-
- static void DeviceRotated(app_device_orientation_e orientation, void *user_data)
- {
- switch(orientation)
- {
- case APP_DEVICE_ORIENTATION_0:
- break;
- case APP_DEVICE_ORIENTATION_90:
- break;
- case APP_DEVICE_ORIENTATION_180:
- break;
- case APP_DEVICE_ORIENTATION_270:
- break;
- }
- }
-
-};
-
-Framework::Framework(Framework::Observer& observer, int *argc, char ***argv, const std::string& name)
-: mObserver(observer),
- mInitialised(false),
- mRunning(false),
- mArgc(argc),
- mArgv(argv),
- mName(name),
- mBundleName(""),
- mBundleId(""),
- mAbortHandler(boost::bind(&Framework::AbortCallback, this)),
- mImpl(NULL)
-{
- XInitThreads();
- mImpl = new Impl(this);
-}
-
-Framework::~Framework()
-{
- if (mRunning)
- {
- Quit();
- }
-
- delete mImpl;
-}
-
-void Framework::Run()
-{
- mRunning = true;
-
- app_efl_main(mArgc, mArgv, &mImpl->mEventCallback, this);
-
- mRunning = false;
-}
-
-void Framework::Quit()
-{
- app_efl_exit();
-}
-
-bool Framework::IsMainLoopRunning()
-{
- return mRunning;
-}
-
-void Framework::AddAbortCallback(boost::function<void(void)> callBack)
-{
- mImpl->mAbortCallBack = callBack;
-}
-
-std::string Framework::GetBundleName() const
-{
- return mBundleName;
-}
-
-void Framework::SetBundleName(const std::string& name)
-{
- mBundleName = name;
-}
-
-std::string Framework::GetBundleId() const
-{
- return mBundleId;
-}
-
-void Framework::SetBundleId(const std::string& id)
-{
- mBundleId = id;
-}
-
-void Framework::AbortCallback( )
-{
- // if an abort call back has been installed run it.
- if (mImpl->mAbortCallBack)
- {
- mImpl->mAbortCallBack();
- }
- else
- {
- Quit();
- }
-}
-
-bool Framework::SlpAppStatusHandler(int type)
-{
- switch (type)
- {
- case APP_CREATE:
- {
- mInitialised = true;
-
- // Connect to abnormal exit signals
- mAbortHandler.AbortOnSignal( SIGINT );
- mAbortHandler.AbortOnSignal( SIGQUIT );
- mAbortHandler.AbortOnSignal( SIGKILL );
-
- mObserver.OnInit();
- break;
- }
-
- case APP_RESET:
- mObserver.OnReset();
- break;
-
- case APP_RESUME:
- mObserver.OnResume();
- break;
-
- case APP_TERMINATE:
- mObserver.OnTerminate();
- break;
-
- case APP_PAUSE:
- mObserver.OnPause();
- break;
-
- case APP_LANGUAGE_CHANGE:
- mObserver.OnLanguageChanged();
- break;
-
- default:
- break;
- }
-
- return true;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_FRAMEWORK_H__
-#define __DALI_INTERNAL_FRAMEWORK_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-#include <boost/function.hpp>
-
-// INTERNAL INCLUDES
-#include "abort-handler.h"
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-/**
- * The Framework class is used to register callbacks with the SLP platform so that
- * we know when any of the application lifecycle events occur. This includes events
- * like when our application is to be initialised, terminated, paused, resumed etc.
- */
-class Framework
-{
-public:
-
- /**
- * Observer class for the framework.
- */
- class Observer
- {
- public:
-
- /**
- * Invoked when the application is to be initialised.
- */
- virtual void OnInit() {}
-
- /**
- * Invoked when the application is to be terminated.
- */
- virtual void OnTerminate() {}
-
- /**
- * Invoked when the application is to be paused.
- */
- virtual void OnPause() {}
-
- /**
- * Invoked when the application is to be resumed.
- */
- virtual void OnResume() {}
-
- /**
- * Invoked when the application is to be reset.
- */
- virtual void OnReset() {}
-
- /**
- * Invoked when the language of the device is changed.
- */
- virtual void OnLanguageChanged() {}
- };
-
-public:
-
- /**
- * Constructor
- * @param[in] observer The observer of the Framework.
- * @param[in] argc A pointer to the number of arguments.
- * @param[in] argv A pointer the the argument list.
- */
- Framework(Observer& observer, int* argc, char ***argv, const std::string& name);
-
- /**
- * Destructor
- */
- ~Framework();
-
-public:
-
- /**
- * Runs the main loop of framework
- */
- void Run();
-
- /**
- * Quits the main loop
- */
- void Quit();
-
- /**
- * Checks whether the main loop of the framework is running.
- * @return true, if the main loop is running, false otherwise.
- */
- bool IsMainLoopRunning();
-
- /**
- * If the main loop aborts unexpectedly, then the connected callback function is called.
- * @param[in] callBack The function to call.
- * @note Only one callback can be registered. The last callback to be set will be called on abort.
- */
- void AddAbortCallback(boost::function<void(void)> callBack);
-
- /**
- * Gets bundle name which was passed in app_reset callback.
- */
- std::string GetBundleName() const;
-
- /**
- * Gets bundle id which was passed in app_reset callback.
- */
- std::string GetBundleId() const;
-
-private:
-
- // Undefined
- Framework(const Framework&);
- Framework& operator=(Framework&);
-
-private:
- /**
- * Called by the SLP framework when an application lifecycle event occurs.
- * @param[in] type The type of event occurred.
- */
- bool SlpAppStatusHandler(int type);
-
- /**
- * Called app_reset callback was called with bundle.
- */
- void SetBundleName(const std::string& name);
-
- /**
- * Called app_reset callback was called with bundle.
- */
- void SetBundleId(const std::string& id);
-
- /**
- * Called if the application is aborted.
- */
- void AbortCallback();
-
-private:
- Observer& mObserver;
- bool mInitialised;
- bool mRunning;
- int* mArgc;
- char*** mArgv;
- std::string mName;
- std::string mBundleName;
- std::string mBundleId;
- AbortHandler mAbortHandler;
-
-private: // impl members
-
- struct Impl;
- Impl* mImpl;
-
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_FRAMEWORK_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "livebox-plugin-impl.h"
-
-// EXTERNAL_HEADERS
-#include <dali/integration-api/debug.h>
-
-#include <Ecore_X.h>
-#include <livebox-service.h>
-
-// INTERNAL HEADERS
-#include <internal/command-line-options.h>
-#include <internal/common/adaptor-impl.h>
-#include <internal/common/ecore-x/ecore-x-render-surface-factory.h>
-#include <internal/common/ecore-x/pixmap-render-surface.h>
-#include <slp-logging.h>
-
-
-namespace Dali
-{
-
-namespace SlpPlatform
-{
-class SlpPlatformAbstraction;
-}
-
-namespace Integration
-{
-class Core;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-#if defined(DEBUG_ENABLED)
-namespace
-{
-Integration::Log::Filter* gLiveboxPluginLogFilter = Integration::Log::Filter::New(Debug::Verbose, false);
-} // unnamed namespace
-
-#endif
-
-namespace
-{
-boost::thread_specific_ptr<LiveboxPlugin> gThreadLocalLivebox;
-}
-
-
-// Static methods
-
-/////////////////////////////////////////////////////////////////////////////////////////////////
-// Client Callbacks
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-/**
- * LiveboxCreated will be called when the livebox instance was created on viewer
- * It is called once.
- */
-static int LiveboxCreated(const char *content_info, int w, int h, double period, void *data)
-{
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
-
- DALI_LOG_INFO(gLiveboxPluginLogFilter, Debug::General, "[%s] buffer %d x %d\n", __FUNCTION__, w, h);
-
- // error handling for buffer size
- if(w < 1 || h < 1)
- {
- livebox_service_get_size(LB_SIZE_TYPE_1x1, &w, &h); // default size
- }
-
- liveboxPlugin->OnLiveboxCreated(content_info, w, h, period);
-
- return 0;
-}
-
-static int LiveboxDestroyed(void *data)
-{
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
- liveboxPlugin->OnLiveboxDestroyed();
-
- return 0;
-
-}
-
-static int LiveboxEventCallback(enum livebox_event_type event, double timestamp, double x, double y, void *data)
-{
- //3 feed event to adaptor for livebox
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
- PositionSize pixmapSize = liveboxPlugin->mSurface->GetPositionSize();
-
- // calculate pixel value from relative value[0.0~1.0f] of position
- int boxX = pixmapSize.width * x;
- int boxY = pixmapSize.height * y;
-
- switch (event)
- {
- case LIVEBOX_EVENT_MOUSE_IN:
- {
- TouchPoint point(0, TouchPoint::Motion, boxX, boxY);
- // the timestamp was calculated by ( tv_sec + tv_usec / 1000000 )
- liveboxPlugin->OnLiveboxTouchEvent(point, static_cast<unsigned int>(timestamp * 1000 * 1000));
- break;
- }
- case LIVEBOX_EVENT_MOUSE_OUT:
- {
- TouchPoint point(0, TouchPoint::Leave, boxX, boxY);
- liveboxPlugin->OnLiveboxTouchEvent(point, static_cast<unsigned int>(timestamp * 1000 * 1000));
- break;
- }
- case LIVEBOX_EVENT_MOUSE_DOWN:
- {
- TouchPoint point(0, TouchPoint::Down, boxX, boxY);
- liveboxPlugin->OnLiveboxTouchEvent(point, static_cast<unsigned int>(timestamp * 1000 * 1000));
- break;
- }
- case LIVEBOX_EVENT_MOUSE_MOVE:
- {
- TouchPoint point(0, TouchPoint::Motion, boxX, boxY);
- liveboxPlugin->OnLiveboxTouchEvent(point, static_cast<unsigned int>(timestamp * 1000 * 1000));
- break;
- }
- case LIVEBOX_EVENT_MOUSE_UP:
- {
- TouchPoint point(0, TouchPoint::Up, boxX, boxY);
- liveboxPlugin->OnLiveboxTouchEvent(point, static_cast<unsigned int>(timestamp * 1000 * 1000));
- break;
- }
- case LIVEBOX_EVENT_KEY_DOWN:
- case LIVEBOX_EVENT_KEY_UP:
-
- default:
- break;
- }
-
- return 0;
-}
-
-static int LiveboxResized(int w, int h, void *data)
-{
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
-
- liveboxPlugin->OnLiveboxResized(w, h);
-
- return 0;
-}
-
-static int LiveboxClientSetPeriod(double period, void *data)
-{
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
- liveboxPlugin->OnPeriodUpdated(period);
-
- return 0;
-}
-
-static int LiveboxClientUpdated(void *data)
-{
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
- liveboxPlugin->OnUpdateRequested();
-
- return 0;
-}
-
-static int LiveboxClientPaused(void *data)
-{
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
- liveboxPlugin->OnPause();
-
- return 0;
-}
-static int LiveboxClientResumed(void *data)
-{
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
- liveboxPlugin->OnResume();
-
- return 0;
-}
-
-static int GlanceCreated(double x, double y, int w, int h, void *data)
-{
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
-
- // calculate pixel value from relative value[0.0~1.0f] of position
- int arrowX = w * x;
- int arrowY = h * y;
-
- liveboxPlugin->OnGlanceCreated(arrowX, arrowY, w, h);
-
- return 0;
-}
-
-static int GlanceDestroyed(void *data)
-{
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
- liveboxPlugin->OnGlanceDestroyed();
-
- return 0;
-}
-
-static int GlanceEventCallback(enum livebox_event_type event, double timestamp, double x, double y, void *data)
-{
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
- liveboxPlugin->OnGlanceTouchEvent();
-
- return 0;
-}
-static int GlanceMoved(double x, double y, int w, int h, void *data)
-{
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
-
- // calculate pixel value from relative value[0.0~1.0f] of position
- int arrowX = w * x;
- int arrowY = h * y;
- liveboxPlugin->OnGlanceMoved(arrowX, arrowY, w, h);
-
- return 0;
-}
-
-static int GlanceScriptEventCalback(const char *emission, const char *source, struct livebox_event_info *info, void *data)
-{
- LiveboxPlugin* liveboxPlugin( (LiveboxPlugin*)data );
- liveboxPlugin->OnGlanceScriptEventCallback(emission, source, info);
-
- return 0;
-}
-
-static Eina_Bool LiveboxDamageCallback(void *data, int type, void *event)
-{
- LiveboxPlugin* liveboxPlugin = (LiveboxPlugin*)data;
- Ecore_X_Event_Damage *ev = (Ecore_X_Event_Damage *)event;
-
- // get the EFL type for the surface
- Any surface = liveboxPlugin->mSurface->GetSurface();
-
- Ecore_X_Pixmap pixmap = AnyCast<Ecore_X_Pixmap>(surface);
-
- if (!ev || !liveboxPlugin->mDamage)
- {
- return ECORE_CALLBACK_PASS_ON;
- }
- if ((Ecore_X_Drawable)pixmap != ev->drawable)
- {
- return ECORE_CALLBACK_PASS_ON;
- }
-
- // handle with damage area : we need it to get damage notify continuously
- Ecore_X_Region parts;
- parts = ecore_x_region_new(NULL, 0);
- ecore_x_damage_subtract(liveboxPlugin->mDamage, 0, parts);
- ecore_x_region_free(parts);
-
- // send update signal to provider
- liveboxPlugin->OnDamaged();
-
- return EINA_TRUE;
-}
-
-LiveboxPlugin::LiveboxPlugin(Dali::LiveboxPlugin& liveboxPlugin, int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout)
-: mLiveboxPlugin(liveboxPlugin),
- mFramework(NULL),
- mCommandLineOptions(NULL),
- mAdaptor(NULL),
- mName(name),
- mInitialized(false),
- mBaseLayout(baseLayout),
- mLiveboxHandle(NULL),
- mTitle(""),
- mContent(""),
- mPeriod(0.0f),
- mGlanceGeometry(-1, -1, -1, -1),
- mDamageEventHandler(NULL),
- mDamage(0),
- mSurface(NULL)
-{
- // make sure we don't create the local thread liveboxPlugin instance twice
- DALI_ASSERT_ALWAYS(gThreadLocalLivebox.get() == NULL && "Cannot create more than one LiveboxPlugin per thread" );
-
- // reset is used to store a new value associated with this thread
- gThreadLocalLivebox.reset(this);
-
- // get log settings
- const char* resourceLogOption = std::getenv(DALI_ENV_ENABLE_LOG);
- unsigned int logOpts = Integration::Log::ParseLogOptions(resourceLogOption);
-
- // livebox plugin thread will send its logs to SLP Platform's LogMessage handler.
- Dali::Integration::Log::InstallLogFunction(Dali::SlpPlatform::LogMessage, logOpts);
-
- mCommandLineOptions = new CommandLineOptions(*argc, *argv);
-
- mFramework = new Framework(*this, argc, argv, name);
-}
-
-LiveboxPlugin::~LiveboxPlugin()
-{
- delete mFramework;
- delete mCommandLineOptions;
- delete mAdaptor;
-
- // uninstall it on this thread.
- Dali::Integration::Log::UninstallLogFunction();
-
- gThreadLocalLivebox.release();
-}
-
-void LiveboxPlugin::Run()
-{
- // Run the liveboxPlugin
- mFramework->Run();
-}
-
-void LiveboxPlugin::Quit()
-{
- AddIdle(boost::bind(&LiveboxPlugin::QuitFromMainLoop, this));
-}
-
-void LiveboxPlugin::QuitFromMainLoop()
-{
- if(mAdaptor)
- {
- mAdaptor->Stop();
- }
-
- mTerminatedSignalV2.Emit( mLiveboxPlugin );
- mTerminatedSignal(mLiveboxPlugin); // deprecated
-
- mFramework->Quit();
-
- mInitialized = false;
-}
-
-
-void LiveboxPlugin::OnInit()
-{
- mFramework->AddAbortCallback(boost::bind(&LiveboxPlugin::QuitFromMainLoop, this));
-
- // real initialize process should be done in OnReset()
-}
-
-
-void LiveboxPlugin::CreateSurface(Ecore_X_Pixmap pixmap)
-{
- Any display;
-
- if(mSurface)
- {
- display = mSurface->GetMainDisplay();
- }
-
- PositionSize pixmapSize;
- int depth = ecore_x_pixmap_depth_get(pixmap);
-
- ecore_x_pixmap_geometry_get(pixmap, &pixmapSize.x, &pixmapSize.y, &pixmapSize.width, &pixmapSize.height);
-
- mSurface = ECoreX::CreatePixmapSurface( pixmapSize, pixmap, display, "", depth == 32 ? true : false );
-
- DALI_LOG_INFO(gLiveboxPluginLogFilter, Debug::General, "[%s] pixmap[%x] %d x %d (%d)\n", __FUNCTION__, pixmap, pixmapSize.width, pixmapSize.height, depth);
-
- // limit 30 fps
- mSurface->SetRenderMode(Dali::RenderSurface::RENDER_30FPS);
-
- // callback damage notify : in damanage callback it should call 'livebox_client_update_box'
- if(mDamage)
- {
- ecore_x_damage_free(mDamage);
- }
- else
- {
- // register damage notify callback
- mDamageEventHandler = ecore_event_handler_add(ECORE_X_EVENT_DAMAGE_NOTIFY, LiveboxDamageCallback, this);
- }
- mDamage = ecore_x_damage_new (pixmap, ECORE_X_DAMAGE_REPORT_DELTA_RECTANGLES);
-}
-
-void LiveboxPlugin::OnLiveboxCreated(const std::string& content, int width, int height, double period)
-{
- DALI_ASSERT_ALWAYS( NULL == mAdaptor && "OnLiveboxCreated must only be called once" );
-
- Ecore_X_Pixmap pixmap;
-
- mLiveboxHandle = livebox_client_create(false, width, height);
-
- if(mLiveboxHandle == NULL)
- {
- // error
- DALI_LOG_WARNING("failed to create livebox handle\n");
- return;
- }
-
- pixmap = static_cast<Ecore_X_Pixmap>(livebox_client_get_pixmap(mLiveboxHandle));
-
- if (pixmap == 0)
- {
- // error
- DALI_LOG_WARNING("invalid pixmap\n");
- return;
- }
-
- // create pixmap surface
- CreateSurface(pixmap);
-
- mContent = content;
- mPeriod = period;
-
- // create adaptor
- mAdaptor = new Dali::Adaptor(*mSurface);
-
- DALI_LOG_INFO(gLiveboxPluginLogFilter, Debug::General, "[%s] pixmap[%x] content(%s)\n", __FUNCTION__, pixmap, content.c_str());
-
- // adaptor start
- mAdaptor->Start();
-
- // get size type
- mBoxSizeType = static_cast<LiveboxSizeType>(livebox_service_size_type(width, height));
-
- // signal init to livebox
- mInitializedSignalV2.Emit( mLiveboxPlugin );
- mInitializedSignal(mLiveboxPlugin); // deprecated
-}
-
-void LiveboxPlugin::OnLiveboxDestroyed()
-{
- livebox_client_destroy(mLiveboxHandle);
- mLiveboxHandle = NULL;
-
- // disconnect pixmap damage notify
- ecore_event_handler_del(mDamageEventHandler);
- QuitFromMainLoop();
-}
-
-void LiveboxPlugin::OnLiveboxResized(int resizedWidth, int resizedHeight)
-{
- Ecore_X_Pixmap pixmap;
-
- livebox_client_destroy(mLiveboxHandle);
-
- mLiveboxHandle = livebox_client_create(false, resizedWidth, resizedHeight);
-
- // get new livebox buffer
- pixmap = static_cast<Ecore_X_Pixmap>(livebox_client_get_pixmap(mLiveboxHandle));
-
- if (pixmap == 0)
- {
- // error
- DALI_LOG_WARNING("invalid pixmap\n");
- return;
- }
-
- //2 replace surface for adaptor
- // remember old surface
- Dali::RenderSurface* oldSurface = mSurface;
-
- CreateSurface(pixmap);
-
- // the surface will be replaced the next time Dali draws
- mAdaptor->ReplaceSurface( *mSurface ); // this method is synchronous
- // its now safe to delete the old surface
- delete oldSurface;
-
- // get size type
- mBoxSizeType = static_cast<LiveboxSizeType>(livebox_service_size_type(resizedWidth, resizedHeight));
-
- // Emit resized signal to application
- mResizedSignalV2.Emit( mLiveboxPlugin );
- mResizedSignal(mLiveboxPlugin); // deprecated
-}
-
-void LiveboxPlugin::OnLiveboxTouchEvent(TouchPoint& point, unsigned int timeStamp)
-{
- mAdaptor->FeedTouchPoint( point, timeStamp );
-}
-
-void LiveboxPlugin::OnPeriodUpdated(double period)
-{
- mPeriod = period;
-
- // Emit period updated signal to application
- mPeriodUpdatedSignal(mLiveboxPlugin);
-}
-
-void LiveboxPlugin::OnUpdateRequested()
-{
- // Emit update requested signal to application
- mUpdateRequestedSignal(mLiveboxPlugin);
-}
-
-void LiveboxPlugin::OnGlanceCreated(int arrowX, int arrowY, int width, int height)
-{
- // store pd information
- mGlanceGeometry = PositionSize(arrowX, arrowY, width, height);
- mGlanceCreatedSignalV2.Emit( mLiveboxPlugin );
- mGlanceCreatedSignal(mLiveboxPlugin); // deprecated
-}
-
-void LiveboxPlugin::OnGlanceDestroyed()
-{
- // make pd information as invalid
- mGlanceGeometry = PositionSize(-1, -1, -1, -1);
- mGlanceDestroyedSignalV2.Emit( mLiveboxPlugin );
- mGlanceDestroyedSignal(mLiveboxPlugin); // deprecated
-}
-
-void LiveboxPlugin::OnGlanceTouchEvent()
-{
- // TODO: handle the touch point
-
- mGlanceTouchedSignalV2.Emit( mLiveboxPlugin );
- mGlanceTouchedSignal(mLiveboxPlugin); // deprecated
-}
-
-void LiveboxPlugin::OnGlanceMoved(int arrowX, int arrowY, int width, int height)
-{
- // TODO: need to do something here?
- mGlanceGeometry = PositionSize(arrowX, arrowY, width, height);
- mGlanceMovedSignalV2.Emit( mLiveboxPlugin );
- mGlanceMovedSignal(mLiveboxPlugin); // deprecated
-}
-
-void LiveboxPlugin::OnGlanceScriptEventCallback(std::string emission, std::string source, struct livebox_event_info *info)
-{
- mGlanceBarEventInfo.emission = emission;
- mGlanceBarEventInfo.source = source;
-
- mGlanceBarEventInfo.pointer.x = info->pointer.x;
- mGlanceBarEventInfo.pointer.y = info->pointer.y;
- mGlanceBarEventInfo.pointer.down = info->pointer.down;
-
- mGlanceBarEventInfo.part.sx = info->part.sx;
- mGlanceBarEventInfo.part.sy = info->part.sy;
- mGlanceBarEventInfo.part.ex = info->part.ex;
- mGlanceBarEventInfo.part.ey = info->part.ey;
-
- mGlanceScriptEventSignalV2.Emit( mLiveboxPlugin );
- mGlanceScriptEventSignal(mLiveboxPlugin); // deprecated
-}
-
-void LiveboxPlugin::OnDamaged()
-{
- PositionSize pixmapSize = mSurface->GetPositionSize();
-
- if(!mTitle.empty())
- {
- livebox_client_update_box(pixmapSize.width, pixmapSize.height, mContent.c_str(), mTitle.c_str());
- }
- else
- {
- livebox_client_update_box(pixmapSize.width, pixmapSize.height, mContent.c_str(), mName.c_str());
- }
-}
-
-void LiveboxPlugin::OnTerminate()
-{
- // we've been told to quit by AppCore, ecore_x_destroy has been called, need to quit synchronously
- QuitFromMainLoop();
-}
-
-void LiveboxPlugin::OnPause()
-{
- mAdaptor->Pause();
- mPausedSignalV2.Emit( mLiveboxPlugin );
- mPausedSignal(mLiveboxPlugin); // deprecated
-}
-
-void LiveboxPlugin::OnResume()
-{
- mResumedSignalV2.Emit( mLiveboxPlugin );
- mResumedSignal(mLiveboxPlugin); // deprecated
- mAdaptor->Resume();
-}
-
-void LiveboxPlugin::OnReset()
-{
- // initialize liblivebox-client
- int ret;
-
- // callback functions which will be called from liblivebox-client
- struct livebox_event_table table;
-
- /**
- * For Livebox
- */
- table.create = LiveboxCreated; // called once the livebox instance is created
- table.destroy = LiveboxDestroyed; // called when the livebox instance was deleted
- table.event = LiveboxEventCallback;
- table.resize = LiveboxResized; // called whenever the livebox instance is resized
-
- /**
- * For Glance bar
- */
- table.create_glance = GlanceCreated; // called when pd should be opened
- table.destroy_glance = GlanceDestroyed; // called when pd should be closed
- table.event_glance = GlanceEventCallback;
- table.move_glance = GlanceMoved;
- table.script_event = GlanceScriptEventCalback;
-
- /**
- * For Client
- */
- table.pause = LiveboxClientPaused; // called when the livebox is invisible
- table.resume = LiveboxClientResumed; // called when the livebox is visible again
- table.update = LiveboxClientUpdated;
- table.set_period = LiveboxClientSetPeriod;
-
- table.data = this;
-
- ret = livebox_client_initialize(mFramework->GetBundleId().c_str(), &table);
-
- DALI_LOG_INFO(gLiveboxPluginLogFilter, Debug::General, "[%s] livebox_client_initialize with bundle id(%s) returns %d\n", __FUNCTION__, mFramework->GetBundleId().c_str(), ret);
-
- if(ret < 0)
- {
- OnTerminate();
- return;
- }
-
- mInitialized = true;
-}
-
-void LiveboxPlugin::OnLanguageChanged()
-{
- mLanguageChangedSignalV2.Emit( mLiveboxPlugin );
- mLanguageChangedSignal(mLiveboxPlugin); // deprecated
-}
-
-bool LiveboxPlugin::AddIdle(boost::function<void(void)> callBack)
-{
- return mAdaptor->AddIdle(callBack);
-}
-
-Dali::LiveboxPlugin& LiveboxPlugin::Get()
-{
- DALI_ASSERT_ALWAYS( gThreadLocalLivebox.get() != NULL && "LiveboxPlugin not instantiated" );
-
- return gThreadLocalLivebox->mLiveboxPlugin;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
+++ /dev/null
-#ifndef __DALI_INTERNAL_LIVEBOX_H__
-#define __DALI_INTERNAL_LIVEBOX_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
-#include <boost/function.hpp>
-#include <boost/thread.hpp>
-
-#include <dali/public-api/math/rect.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-
-#include <Ecore_X.h>
-#include <Ecore.h>
-
-#include <livebox-client.h>
-
-// INTERNAL INCLUDES
-#include <public-api/adaptor-framework/livebox-plugin.h>
-#include <internal/framework.h>
-
-namespace Dali
-{
-
-class Adaptor;
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class CommandLineOptions;
-class EventLoop;
-
-typedef Dali::Rect<int> PositionSize;
-
-namespace ECoreX
-{
-class RenderSurface;
-}
-
-/**
- * Implementation of the LiveboxPlugin class.
- */
-class LiveboxPlugin : public Framework::Observer
-{
-public:
-
- typedef Dali::LiveboxPlugin::LiveboxPluginSignalV2 LiveboxPluginSignalV2;
-
- /**
- * Constructor
- * @param[in] livebox The public instance of the LiveboxPlugin
- * @param[in] argc A pointer to the number of arguments
- * @param[in] argv A pointer to the argument list
- * @param[in] name A name of livebox
- * @param[in] baseLayout The base layout that the livebox has been written for
- */
- LiveboxPlugin(Dali::LiveboxPlugin& livebox, int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout);
-
- /**
- * Destructor
- */
- virtual ~LiveboxPlugin();
-
-public:
-
- /**
- * @copydoc Dali::LiveboxPlugin::SetTitle()
- */
- void SetTitle(const std::string& title) {mTitle = title; };
-
- /**
- * @copydoc Dali::LiveboxPlugin::SetContent()
- */
- void SetContent(const std::string& content) {mContent = content; };
-
- /**
- * @copydoc Dali::LiveboxPlugin::GetGlanceBarGeometry()
- */
- const PositionSize& GetGlanceBarGeometry() const { return mGlanceGeometry; };
-
- /**
- * @copydoc Dali::LiveboxPlugin::GetGlanceBarEventInfo()
- */
- const GlanceBarEventInfo& GetGlanceBarEventInfo() const { return mGlanceBarEventInfo; };
-
- /**
- * @copydoc Dali::LiveboxPlugin::GetLiveboxSizeType()
- */
- LiveboxSizeType GetLiveboxSizeType() const { return mBoxSizeType; };
-
- /**
- * @copydoc Dali::LiveboxPlugin::Run()
- */
- void Run();
-
- /**
- * @copydoc Dali::LiveboxPlugin::Quit()
- */
- void Quit();
-
- /**
- * @copydoc Dali::LiveboxPlugin::AddIdle()
- */
- bool AddIdle(boost::function<void(void)> callBack);
-
- /**
- * @copydoc Dali::LiveboxPlugin::Get();
- */
- static Dali::LiveboxPlugin& Get();
-
-
-public: // From Framework::Observer
-
- /**
- * Called when the framework is initialised.
- */
- virtual void OnInit();
-
- /**
- * Called when the framework is terminated.
- */
- virtual void OnTerminate();
-
- /**
- * Called when the framework is paused.
- */
- virtual void OnPause();
-
- /**
- * Called when the framework resumes from a paused state.
- */
- virtual void OnResume();
-
- /**
- * Called when the framework informs the livebox that it should reset itself.
- */
- virtual void OnReset();
-
- /**
- * Called when the framework informs the livebox that the language of the device has changed.
- */
- virtual void OnLanguageChanged();
-
-public:
- /**
- * Client handlers
- */
-
- /**
- * Notify the livebox was created.
- *
- * @param[in] pkgname package name
- * @param[in] id livebox id string
- * @param[in] content content string of livebox
- * @param[in] width width of livebox
- * @param[in] height height of livebox
- */
- void OnLiveboxCreated(const std::string& content, int width, int height, double period);
-
- /**
- * Notify the livebox should be destroyed.
- */
- void OnLiveboxDestroyed();
-
- /**
- * Notify the client should be resized.
- *
- * @param[in] resizedWidth new width of livebox
- * @param[in] resizedHeight new height of livebox
- */
- void OnLiveboxResized(int resizedWidth, int resizedHeight);
-
- /**
- * Send event to livebox.
- *
- * @param[in] point touch point
- * @param[in] timeStamp time value of event
- */
- void OnLiveboxTouchEvent(TouchPoint& point, unsigned int timeStamp);
-
- void OnPeriodUpdated(double period);
- void OnUpdateRequested();
-
- /**
- * Notify the glance was created.
- *
- * @param[in] pdWidth width of pd
- * @param[in] pdHeight height of pd
- * @param[in] arrowX x position of pd's arrow
- * @param[in] arrowY y position of pd's arrow
- */
- void OnGlanceCreated(int width, int height, int arrowX, int arrowY);
-
- /**
- * Notify the glance should be destroyed.
- */
- void OnGlanceDestroyed();
-
- void OnGlanceTouchEvent();
- void OnGlanceMoved(int arrowX, int arrowY, int width, int height);
- void OnGlanceScriptEventCallback(std::string emission, std::string source, struct livebox_event_info *info);
-
- /**
- * Notify the surface was damaged.
- * When it was damager, this client should send update to master
- */
- void OnDamaged();
-
-public: // Signals
-
- /**
- * @copydoc Dali::LiveboxPlugin::InitializedSignal()
- */
- LiveboxPluginSignalV2& InitializedSignal() { return mInitializedSignalV2; }
-
- /**
- * @copydoc Dali::LiveboxPlugin::TerminatedSignal()
- */
- LiveboxPluginSignalV2& TerminatedSignal() { return mTerminatedSignalV2; }
-
- /**
- * @copydoc Dali::LiveboxPlugin::PausedSignal()
- */
- LiveboxPluginSignalV2& PausedSignal() { return mPausedSignalV2; }
-
- /**
- * @copydoc Dali::LiveboxPlugin::ResumedSignal()
- */
- LiveboxPluginSignalV2& ResumedSignal() { return mResumedSignalV2; }
-
- /**
- * @copydoc Dali::LiveboxPlugin::ResizedSignal()
- */
- LiveboxPluginSignalV2& ResizedSignal() { return mResizedSignalV2; }
-
- /**
- * @copydoc Dali::LiveboxPlugin::GlanceCreatedSignal()
- */
- LiveboxPluginSignalV2& GlanceCreatedSignal() { return mGlanceCreatedSignalV2; }
-
- /**
- * @copydoc Dali::LiveboxPlugin::GlanceDestroyedSignal()
- */
- LiveboxPluginSignalV2& GlanceDestroyedSignal() { return mGlanceDestroyedSignalV2; }
-
- /**
- * @copydoc Dali::LiveboxPlugin::GlanceTouchedSignal()
- */
- LiveboxPluginSignalV2& GlanceTouchedSignal() { return mGlanceTouchedSignalV2; }
-
- /**
- * @copydoc Dali::LiveboxPlugin::GlanceMovedSignal()
- */
- LiveboxPluginSignalV2& GlanceMovedSignal() { return mGlanceMovedSignalV2; }
-
- /**
- * @copydoc Dali::LiveboxPlugin::GlanceScriptEventSignal()
- */
- LiveboxPluginSignalV2& GlanceScriptEventSignal() { return mGlanceScriptEventSignalV2; }
-
- /**
- * @copydoc Dali::LiveboxPlugin::LanguageChangedSignal()
- */
- LiveboxPluginSignalV2& LanguageChangedSignal() { return mLanguageChangedSignalV2; }
-
-private:
-
- // Undefined
- LiveboxPlugin(const LiveboxPlugin&);
- LiveboxPlugin& operator=(LiveboxPlugin&);
-
-private:
-
- /**
- * Create pixmap surface for mSurface.
- * If there is no mSurface, it will create mSurface with new display.
- * If mSurface is existed already, then it uses existed display but overwrite mSurface by new one
- * It make a callback for damage notify automatically
- */
- void CreateSurface(Ecore_X_Pixmap pixmap);
-
- /**
- * Quits from the main loop
- */
- void QuitFromMainLoop();
-
-private:
-
- LiveboxPluginSignalV2 mInitializedSignalV2;
- LiveboxPluginSignalV2 mTerminatedSignalV2;
- LiveboxPluginSignalV2 mPausedSignalV2;
- LiveboxPluginSignalV2 mResumedSignalV2;
- LiveboxPluginSignalV2 mResizedSignalV2;
- LiveboxPluginSignalV2 mGlanceCreatedSignalV2;
- LiveboxPluginSignalV2 mGlanceDestroyedSignalV2;
- LiveboxPluginSignalV2 mGlanceTouchedSignalV2;
- LiveboxPluginSignalV2 mGlanceMovedSignalV2;
- LiveboxPluginSignalV2 mGlanceScriptEventSignalV2;
- LiveboxPluginSignalV2 mLanguageChangedSignalV2;
-
- Dali::LiveboxPlugin& mLiveboxPlugin;
-
- Framework* mFramework;
-
- CommandLineOptions* mCommandLineOptions;
-
- Dali::Adaptor* mAdaptor;
- std::string mName;
-
- bool mInitialized;
- DeviceLayout mBaseLayout;
-
- // client properties
- livebox_h mLiveboxHandle;
- std::string mTitle;
- std::string mContent;
- double mPeriod;
-
- PositionSize mGlanceGeometry;
- GlanceBarEventInfo mGlanceBarEventInfo;
-
- LiveboxSizeType mBoxSizeType;
-
-public:
- /* for rendering control : these public members will be used in static function */
- Ecore_Event_Handler* mDamageEventHandler;
- Ecore_X_Damage mDamage;
- ECoreX::RenderSurface* mSurface;
-
-public:
- inline static LiveboxPlugin& GetImplementation(Dali::LiveboxPlugin& livebox) { return *livebox.mImpl; }
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_LIVEBOX_H__
-
+++ /dev/null
-# Application
-
-tizen_evas_plugin_internal_src_files = \
- $(tizen_evas_plugin_internal_src_dir)/evas-plugin-impl.cpp
-
-tizen_native_buffer_plugin_internal_src_files = \
- $(tizen_native_buffer_plugin_internal_src_dir)/native-buffer-plugin-impl.cpp
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "evas-plugin-impl.h"
-
-// EXTERNAL HEADERS
-#include <dali/public-api/dali-core.h>
-#include <dali/integration-api/debug.h>
-
-#include <Ecore_IMF_Evas.h>
-
-// INTERNAL HEADERS
-#include <dali/public-api/adaptor-framework/common/accessibility-manager.h>
-#include <dali/public-api/adaptor-framework/common/clipboard-event-notifier.h>
-#include <dali/public-api/adaptor-framework/common/imf-manager.h>
-
-#include <internal/common/adaptor-impl.h>
-#include "mobile-render-surface-factory.h"
-#include <internal/common/ecore-x/pixmap-render-surface.h>
-#include <internal/common/trigger-event.h>
-
-namespace Dali
-{
-
-namespace SlpPlatform
-{
-class SlpPlatformAbstraction;
-}
-
-namespace Integration
-{
-class Core;
-}
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gEvasPluginLogFilter = Debug::Filter::New(Debug::Verbose, true, "LOG_EVAS_PLUGIN");
-#endif
-
-const char * CLIPBOARD_ATOM = "CBHM_MSG";
-const char * CLIPBOARD_SET_OWNER_MESSAGE = "SET_OWNER";
-
-/**
- * Evas_Modifier enums in Ecore_Input.h do not match Ecore_Event_Modifier in Ecore_Input.h.
- * This function converts from Evas_Modifier to Ecore_Event_Modifier enums.
- * @param[in] evasModifier the Evas_Modifier input.
- * @return the Ecore_Event_Modifier output.
- */
-unsigned int EvasModifierToEcoreModifier(Evas_Modifier* evasModifier)
-{
- Eina_Bool control, alt, shift, altGr, win;
-
- control = evas_key_modifier_is_set(evasModifier, "Control");
- alt = evas_key_modifier_is_set(evasModifier, "Alt");
- shift = evas_key_modifier_is_set(evasModifier, "Shift");
- altGr = evas_key_modifier_is_set(evasModifier, "AltGr");
- win = evas_key_modifier_is_set(evasModifier, "Win");
- win = evas_key_modifier_is_set(evasModifier, "Super");
- win = evas_key_modifier_is_set(evasModifier, "Hyper");
-
- unsigned int modifier( 0 ); // If no other matches returns NONE.
-
- if ( shift )
- {
- modifier |= ECORE_EVENT_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
- }
-
- if ( alt )
- {
- modifier |= ECORE_EVENT_MODIFIER_ALT;
- }
-
- if ( control )
- {
- modifier |= ECORE_EVENT_MODIFIER_CTRL;
- }
-
- if ( win )
- {
- modifier |= ECORE_EVENT_MODIFIER_WIN;
- }
-
- if ( altGr )
- {
- modifier |= ECORE_EVENT_MODIFIER_ALTGR;
- }
-
- return modifier;
-}
-
-static void _evas_object_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep)
- {
- Evas_Event_Mouse_Down* ev;
- ev = (Evas_Event_Mouse_Down *)event_info;
-
- Evas_Coord rel_x, rel_y;
- Evas_Coord obj_x, obj_y, obj_w, obj_h;
- evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
-
- rel_x = ev->canvas.x - obj_x;
- rel_y = ev->canvas.y - obj_y;
-
- // create dali TouchEvent & SendEvent
- TouchPoint point(0, TouchPoint::Down, rel_x, rel_y);
- ep->OnTouchEvent(point, ev->timestamp);
- }
-}
-
-static void _evas_object_mouse_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep)
- {
- Evas_Event_Mouse_Move *ev;
- ev = (Evas_Event_Mouse_Move *)event_info;
-
- Evas_Coord rel_x, rel_y;
- Evas_Coord obj_x, obj_y, obj_w, obj_h;
- evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
-
- rel_x = ev->cur.canvas.x - obj_x;
- rel_y = ev->cur.canvas.y - obj_y;
-
- // create dali TouchEvent & SendEvent
- TouchPoint point(0, TouchPoint::Motion, rel_x, rel_y);
- ep->OnTouchEvent(point, ev->timestamp);
- }
-}
-
-static void _evas_object_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep)
- {
- Evas_Event_Mouse_Up *ev;
- ev = (Evas_Event_Mouse_Up *)event_info;
-
- Evas_Coord rel_x, rel_y;
- Evas_Coord obj_x, obj_y, obj_w, obj_h;
- evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
-
- rel_x = ev->canvas.x - obj_x;
- rel_y = ev->canvas.y - obj_y;
-
- // create dali TouchEvent & SendEvent
- TouchPoint point(0, TouchPoint::Up, rel_x, rel_y);
- ep->OnTouchEvent(point, ev->timestamp);
- }
-}
-
-static void _evas_object_mouse_wheel_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep)
- {
- Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*)event_info;
- Evas_Coord rel_x, rel_y;
- Evas_Coord obj_x, obj_y, obj_w, obj_h;
- evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
-
- rel_x = ev->canvas.x - obj_x;
- rel_y = ev->canvas.y - obj_y;
-
- MouseWheelEvent wheelEvent(ev->direction, -1 /*Need to check evas modifier*/, Vector2(rel_x, rel_y), ev->z, ev->timestamp);
- ep->OnMouseWheelEvent(wheelEvent);
- }
-}
-
-static void _evas_object_multi_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep)
- {
- Evas_Event_Multi_Down *ev = (Evas_Event_Multi_Down*)event_info;
-
- Evas_Coord rel_x, rel_y;
- Evas_Coord obj_x, obj_y, obj_w, obj_h;
- evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
-
- rel_x = ev->canvas.x - obj_x;
- rel_y = ev->canvas.y - obj_y;
-
- // create dali TouchEvent & SendEvent
- TouchPoint point(ev->device, TouchPoint::Down, rel_x, rel_y);
- ep->OnTouchEvent(point, ev->timestamp);
- }
-}
-
-static void _evas_object_multi_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep)
- {
- Evas_Event_Multi_Up *ev = (Evas_Event_Multi_Up*)event_info;
-
- Evas_Coord rel_x, rel_y;
- Evas_Coord obj_x, obj_y, obj_w, obj_h;
- evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
-
- rel_x = ev->canvas.x - obj_x;
- rel_y = ev->canvas.y - obj_y;
-
- // create dali TouchEvent & SendEvent
- TouchPoint point(ev->device, TouchPoint::Up, rel_x, rel_y);
- ep->OnTouchEvent(point, ev->timestamp);
- }
-}
-static void _evas_object_multi_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep)
- {
- Evas_Event_Multi_Move *ev = (Evas_Event_Multi_Move*)event_info;
-
- Evas_Coord rel_x, rel_y;
- Evas_Coord obj_x, obj_y, obj_w, obj_h;
- evas_object_geometry_get(obj, &obj_x, &obj_y, &obj_w, &obj_h);
-
- rel_x = ev->cur.canvas.x - obj_x;
- rel_y = ev->cur.canvas.y - obj_y;
-
- // create dali TouchEvent & SendEvent
- TouchPoint point(ev->device, TouchPoint::Motion, rel_x, rel_y);
- ep->OnTouchEvent(point, ev->timestamp);
- }
-}
-
-static void _evas_object_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
-
- if(ep)
- {
- Evas_Event_Key_Down* keyEvent( (Evas_Event_Key_Down*)event_info );
- bool eventHandled( false );
-
- if(!keyEvent->keyname)
- {
- return;
- }
-
- Ecore_IMF_Context* imfContext = NULL;
- if ( Dali::Adaptor::IsAvailable() )
- {
- Dali::ImfManager imfManager = Dali::ImfManager::Get();
- if ( imfManager )
- {
- imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
- }
- }
-
- // XF86Stop and XF86Send must skip ecore_imf_context_filter_event.
- if ( imfContext && strcmp( keyEvent->keyname, "XF86Send" ) && strcmp( keyEvent->keyname, "XF86Phone" ) && strcmp( keyEvent->keyname, "XF86Stop" ) )
- {
- Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
- ecore_imf_evas_event_key_down_wrap(keyEvent, &ecoreKeyDownEvent);
-
- eventHandled = ecore_imf_context_filter_event(imfContext,
- ECORE_IMF_EVENT_KEY_DOWN,
- (Ecore_IMF_Event *) &ecoreKeyDownEvent );
-
- // If the event has not been handled by IMF then check if we should reset our IMF context
- if( !eventHandled )
- {
- if ( !strcmp( keyEvent->keyname, "Escape" ) ||
- !strcmp( keyEvent->keyname, "Return" ) ||
- !strcmp( keyEvent->keyname, "KP_Enter" ) )
- {
- ecore_imf_context_reset( imfContext );
- }
- }
- }
-
- // If the event wasn't handled then we should send a key event.
- if ( !eventHandled )
- {
- std::string keyName( keyEvent->keyname );
- std::string keyString( "" );
- int keyCode = ecore_x_keysym_keycode_get(keyEvent->keyname);
- int modifier( EvasModifierToEcoreModifier ( keyEvent->modifiers ) );
- unsigned long time( keyEvent->timestamp );
-
- // Ensure key event string is not NULL as keys like SHIFT have a null string.
- if ( keyEvent->string )
- {
- keyString = keyEvent->string;
- }
-
- KeyEvent daliKeyEvent(keyName, keyString, keyCode, modifier, time, KeyEvent::Down);
- ep->OnKeyEvent( daliKeyEvent );
- }
- }
-}
-
-static void _evas_object_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep)
- {
- // We're consuming key up event so we have to pass to IMF so that it can parse it as well.
- Evas_Event_Key_Up* keyEvent( (Evas_Event_Key_Up*)event_info );
- bool eventHandled( false );
-
- Ecore_IMF_Context* imfContext = NULL;
- if ( Dali::Adaptor::IsAvailable() )
- {
- Dali::ImfManager imfManager = Dali::ImfManager::Get();
- if ( imfManager )
- {
- imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
- }
- }
-
- if ( imfContext && strcmp( keyEvent->keyname, "XF86Send" ) && strcmp( keyEvent->keyname, "XF86Phone" ) && strcmp( keyEvent->keyname, "XF86Stop" ))
- {
- Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
- ecore_imf_evas_event_key_up_wrap(keyEvent, &ecoreKeyUpEvent);
-
- eventHandled = ecore_imf_context_filter_event( imfContext,
- ECORE_IMF_EVENT_KEY_UP,
- (Ecore_IMF_Event *) &ecoreKeyUpEvent );
- }
-
- if ( !eventHandled )
- {
- std::string keyName( keyEvent->keyname );
- std::string keyString( "" );
- int keyCode = ecore_x_keysym_keycode_get(keyEvent->keyname);
- int modifier( EvasModifierToEcoreModifier ( keyEvent->modifiers ) );
- unsigned long time( keyEvent->timestamp );
-
- // Ensure key event string is not NULL as keys like SHIFT have a null string.
- if ( keyEvent->string )
- {
- keyString = keyEvent->string;
- }
-
- KeyEvent daliKeyEvent(keyName, keyString, keyCode, modifier, time, KeyEvent::Up);
- ep->OnKeyEvent( daliKeyEvent );
- }
- }
-}
-
-static void _evas_object_focus_in_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep != NULL && ep->GetEvasImageObject() == obj)
- {
- ep->OnEvasObjectFocusedIn();
- }
-}
-
-static void _evas_object_focus_out_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep != NULL && ep->GetEvasImageObject() == obj)
- {
- ep->OnEvasObjectFocusedOut();
- }
-}
-
-static void _elm_focus_object_focus_in_cb(void *data, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep != NULL && ep->GetElmFocusObject() == obj)
- {
- Evas_Object* win = elm_object_top_widget_get(obj);
- if(strcmp("elm_win", elm_object_widget_type_get(win)) == 0)
- {
- if(elm_win_focus_highlight_enabled_get(win) == EINA_TRUE)
- {
- // To allow that KeyboardFocusManager can handle the keyboard focus
- KeyEvent fakeKeyEvent("", "", 0, 0, 100 /* fake timestamp */, KeyEvent::Down);
- ep->OnKeyEvent( fakeKeyEvent );
- }
- }
- else
- {
- DALI_LOG_ERROR("It is not elm win\n");
- }
-
- evas_object_focus_set(ep->GetEvasImageObject(), EINA_TRUE);
- }
-}
-
-static void _elm_focus_object_focus_out_cb(void *data, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep != NULL && ep->GetElmFocusObject() == obj)
- {
- evas_object_focus_set(ep->GetEvasImageObject(), EINA_FALSE);
- }
-}
-
-static void _canvas_focus_in_cb(void *data, Evas *e, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep != NULL && ep->GetEvasImageObject() == evas_focus_get(e))
- {
- ep->OnEvasObjectFocusedIn();
- }
-}
-
-static void _canvas_focus_out_cb(void *data, Evas *e, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep != NULL && ep->GetEvasImageObject() == evas_focus_get(e))
- {
- ep->OnEvasObjectFocusedOut();
- }
-}
-
-static void _evas_object_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep)
- {
- ep->Move();
- }
-}
-
-static void _evas_object_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep)
- {
- ep->Resize();
- }
-}
-
-static void _evas_render_post_cb(void *data, Evas *e, void *event_info)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- if(ep)
- {
- // call RenderSync when the window surface(onscreen) was presented to LCD.
- ep->RenderSync();
-
- //After first render emit signal to notify
- if(!ep->mFirstRenderCompleteNotified)
- {
- ep->OnFirstRenderCompleted();
- }
- }
-}
-
-/*
- * When the evas plugin is resumed,
- * need to forcely dirty set the evas object on idle time to show again the result of dali rendering.
- * One time should be enough.
- */
-static Eina_Bool _evas_object_dirty_set_idle_cb(void *data)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
-
- if(ep)
- {
- Evas_Object* eo = ep->GetEvasImageObject();
- if(eo)
- {
- /* dirty set to post the result of rendering via evas */
- evas_object_image_pixels_dirty_set(eo, EINA_TRUE);
- }
-
- ep->ClearIdler(false); // clear idler handle without deleting handle. because handle will be deleted by ecore
- }
-
- // we need it once.
- return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool _elm_access_highlight_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- bool ret = false;
-
- if(ep && actionInfo)
- {
- // action_by has NEXT or PREV
- if (actionInfo->action_by == ELM_ACCESS_ACTION_HIGHLIGHT_NEXT)
- {
- ret = ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_HIGHLIGHT_NEXT, actionInfo);
- DALI_LOG_INFO(gEvasPluginLogFilter, Debug::General, "[%s:%d] Next returns %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
- }
- else if (actionInfo->action_by == ELM_ACCESS_ACTION_HIGHLIGHT_PREV)
- {
- ret = ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_HIGHLIGHT_PREV, actionInfo);
- DALI_LOG_INFO(gEvasPluginLogFilter, Debug::General, "[%s:%d] Prev returns %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
- }
- else
- {
- /*
- * In case of access over, action_by has ELM_ACCESS_ACTION_HIGHLIGHT
- * real operation will be done in _elm_access_over_cb
- * so just return true in order to remove the entire focus indicator
- */
-
- /*
- * Even if action_by has intialized value (-1), highlight action is valid
- */
- ret = true;
- }
- }
- else
- {
- DALI_LOG_WARNING("[%s:%d] has no actionInfo\n", __FUNCTION__, __LINE__);
- }
-
- return ret;
-}
-
-static Eina_Bool _elm_access_read_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- bool ret = false;
-
- if(ep)
- {
- PositionSize geometry = ep->GetEvasObjectGeometry();
-
- if(actionInfo)
- {
- ret = ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_READ, actionInfo, (actionInfo->x - geometry.x), (actionInfo->y - geometry.y));
- DALI_LOG_INFO(gEvasPluginLogFilter, Debug::General, "[%s:%d] returns %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
- }
- else
- {
- DALI_LOG_WARNING( "[%s:%d] has no actionInfo\n", __FUNCTION__, __LINE__);
- }
- }
-
- return ret;
-}
-
-static Eina_Bool _elm_access_over_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- bool ret = false;
-
- if(ep)
- {
- PositionSize geometry = ep->GetEvasObjectGeometry();
-
- if(actionInfo)
- {
- ret = ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_OVER, actionInfo, (actionInfo->x - geometry.x), (actionInfo->y - geometry.y));
- DALI_LOG_INFO(gEvasPluginLogFilter, Debug::General, "[%s:%d] returns %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
- }
- else
- {
- DALI_LOG_WARNING( "[%s:%d] has no actionInfo\n", __FUNCTION__, __LINE__);
- }
- }
-
- return ret;
-}
-
-static Eina_Bool _elm_access_highlight_next_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_HIGHLIGHT_NEXT, actionInfo);
-}
-
-static Eina_Bool _elm_access_highlight_prev_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_HIGHLIGHT_PREV, actionInfo);
-}
-
-static Eina_Bool _elm_access_activate_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_ACTIVATE, actionInfo);
-}
-
-static Eina_Bool _elm_access_unhighlight_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_UNHIGHLIGHT, actionInfo);
-}
-
-static Eina_Bool _elm_access_back_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_BACK, actionInfo);
-}
-
-static Eina_Bool _elm_access_value_up_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_UP, actionInfo);
-}
-
-static Eina_Bool _elm_access_value_down_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- return ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_DOWN, actionInfo);
-}
-
-static Eina_Bool _elm_access_scroll_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- bool ret = false;
-
- if(actionInfo && ep)
- {
- Evas_Coord rel_x, rel_y;
- Evas_Coord obj_x, obj_y, obj_w, obj_h;
- Evas_Object* eo = ep->GetEvasImageObject();
-
- if(eo)
- {
- evas_object_geometry_get(eo, &obj_x, &obj_y, &obj_w, &obj_h);
-
- rel_x = actionInfo->x - obj_x;
- rel_y = actionInfo->y - obj_y;
-
- ret = ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_SCROLL, actionInfo, rel_x, rel_y);
- }
- }
- else
- {
- DALI_LOG_WARNING("[%s:%d] has no actionInfo\n", __FUNCTION__, __LINE__);
- }
-
- return ret;
-}
-
-static Eina_Bool _elm_access_mouse_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *actionInfo)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
- bool ret = false;
-
- if(actionInfo && ep)
- {
- Evas_Coord rel_x, rel_y;
- Evas_Coord obj_x, obj_y, obj_w, obj_h;
- Evas_Object* eo = ep->GetEvasImageObject();
-
- if(eo)
- {
- evas_object_geometry_get(eo, &obj_x, &obj_y, &obj_w, &obj_h);
-
- rel_x = actionInfo->x - obj_x;
- rel_y = actionInfo->y - obj_y;
-
- ret = ep->OnAccessibilityActionEvent(ELM_ACCESS_ACTION_MOUSE, actionInfo, rel_x, rel_y);
- }
- }
- else
- {
- DALI_LOG_WARNING("[%s:%d] has no actionInfo\n", __FUNCTION__, __LINE__);
- }
-
- return ret;
-}
-
-static Eina_Bool _ecore_x_event_selection_clear(void *data, int type, void *event)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
-
- if( ep )
- {
- ep->OnEcoreEventSelectionCleared(data, type, event);
- }
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool _ecore_x_event_selection_notify(void *data, int type, void *event)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
-
- if( ep )
- {
- ep->OnEcoreEventSelectionNotified(data, type, event);
- }
-
- return ECORE_CALLBACK_PASS_ON;
-}
-static Eina_Bool _ecore_x_event_client_message(void* data, int type, void* event)
-{
- EvasPlugin* ep = (EvasPlugin*)data;
-
- if( ep )
- {
- ep->OnEcoreEventClientMessaged(data, type, event);
- }
-
- return ECORE_CALLBACK_PASS_ON;
-}
-
-// Copied from x server
-static unsigned int GetCurrentMilliSeconds(void)
-{
- struct timeval tv;
-
- struct timespec tp;
- static clockid_t clockid;
-
- if (!clockid)
- {
-#ifdef CLOCK_MONOTONIC_COARSE
- if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
- (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
- {
- clockid = CLOCK_MONOTONIC_COARSE;
- }
- else
-#endif
- if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
- {
- clockid = CLOCK_MONOTONIC;
- }
- else
- {
- clockid = ~0L;
- }
- }
- if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
- {
- return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
- }
-
- gettimeofday(&tv, NULL);
- return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
-}
-
-EvasPlugin::EvasPlugin(Dali::EvasPlugin& evasPlugin, Evas_Object* parent, bool isTransparent, unsigned int initialWidth, unsigned int initialHeight)
-: mEvasImageObject(NULL),
- mElmAccessObject(NULL),
- mElmFocusObject(NULL),
- mSurface(NULL),
- mFirstRenderCompleteNotified(false),
- mEvasPlugin(evasPlugin),
- mAdaptor(NULL),
- mEvas(NULL),
- mEvasImageObjectGeometry(0, 0, initialWidth, initialHeight),
- mInitialized(false),
- mIsTransparent(isTransparent),
- mHasFocus(false),
- mRenderNotification(NULL),
- mEvasDirtyIdler(NULL)
-{
- DALI_ASSERT_ALWAYS( parent && "No parent object for plugin" );
- mEvas = AnyCast<Evas*>(evas_object_evas_get(parent));
-
- /* create evas object image */
- CreateEvasImageObject(mEvas, initialWidth, initialHeight, isTransparent);
-
- /* create elm access object */
- CreateElmAccessObject(parent);
-
- /* create elm focus object */
- CreateElmFocusObject(parent);
-
- /* create adaptor */
- CreateAdaptor(initialWidth, initialHeight);
-
- /* render post callback */
- evas_event_callback_add(mEvas, EVAS_CALLBACK_RENDER_POST, _evas_render_post_cb, this);
-
- mRenderNotification = new TriggerEvent( boost::bind(&EvasPlugin::Render, this ) );
-
- mSurface->SetRenderNotification( mRenderNotification );
-
- mState = Ready;
-}
-
-EvasPlugin::~EvasPlugin()
-{
- mConnectionTracker.DisconnectAll();
-
- if (mAdaptor)
- {
- Stop();
-
- // delete idler
- ClearIdler();
-
- // no more notifications
- delete mRenderNotification;
-
- // delete evas canvas callback for render sync
- evas_event_callback_del(mEvas, EVAS_CALLBACK_RENDER_POST, _evas_render_post_cb);
-
- delete mAdaptor;
- mAdaptor = NULL;
-
- // delete elm focus object
- DeleteElmFocusObject();
-
- // delete elm access object
- DeleteElmAccessObject();
-
- // delete evas object image
- DeleteEvasImageObject();
-
- if (mSurface)
- {
- delete mSurface;
- mSurface = NULL;
- }
- }
-}
-
-void EvasPlugin::CreateEvasImageObject(Evas* evas, unsigned int initialWidth, unsigned int initialHeight, bool isTransparent)
-{
- /* create evas object */
-
- mEvasImageObject = evas_object_image_filled_add(mEvas);
- evas_object_name_set(mEvasImageObject, "dali-evasplugin");
- evas_object_image_content_hint_set(mEvasImageObject, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
- evas_object_size_hint_align_set(mEvasImageObject, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_size_hint_weight_set(mEvasImageObject, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
- if(isTransparent)
- {
- evas_object_image_alpha_set(mEvasImageObject, EINA_TRUE);
- }
-
- evas_object_move(mEvasImageObject, 0, 0);
- evas_object_image_size_set(mEvasImageObject, initialWidth, initialHeight);
- evas_object_resize(mEvasImageObject, initialWidth, initialHeight);
-
- /* event callback */
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MOUSE_DOWN, _evas_object_mouse_down_cb, this);
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MOUSE_UP, _evas_object_mouse_up_cb, this);
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MOUSE_MOVE, _evas_object_mouse_move_cb, this);
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MOUSE_WHEEL, _evas_object_mouse_wheel_cb, this);
-
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MULTI_DOWN, _evas_object_multi_down_cb, this);
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MULTI_UP, _evas_object_multi_up_cb, this);
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MULTI_MOVE, _evas_object_multi_move_cb, this);
-
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_KEY_DOWN, _evas_object_key_down_cb, this);
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_KEY_UP, _evas_object_key_up_cb, this);
-
- /* move callback */
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_MOVE, _evas_object_move_cb, this);
-
- /* resize callback */
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_RESIZE, _evas_object_resize_cb, this);
-
- /* focus callback */
- evas_event_callback_add(mEvas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _canvas_focus_in_cb, this);
- evas_event_callback_add(mEvas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _canvas_focus_out_cb, this);
-
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_FOCUS_IN, _evas_object_focus_in_cb, this);
- evas_object_event_callback_add(mEvasImageObject, EVAS_CALLBACK_FOCUS_OUT, _evas_object_focus_out_cb, this);
-
- evas_object_show(mEvasImageObject);
-}
-
-void EvasPlugin::DeleteEvasImageObject()
-{
- if(mEvasImageObject)
- {
- /* event callback */
- evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MOUSE_DOWN, _evas_object_mouse_down_cb);
- evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MOUSE_UP, _evas_object_mouse_up_cb);
- evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MOUSE_MOVE, _evas_object_mouse_move_cb);
-
- evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MULTI_DOWN, _evas_object_multi_down_cb);
- evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MULTI_UP, _evas_object_multi_up_cb);
- evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MULTI_MOVE, _evas_object_multi_move_cb);
-
- evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_KEY_DOWN, _evas_object_key_down_cb);
- evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_KEY_UP, _evas_object_key_up_cb);
-
- /* move callback */
- evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_MOVE, _evas_object_move_cb);
-
- /* resize callback */
- evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_RESIZE, _evas_object_resize_cb);
-
- /* focus callback */
- evas_event_callback_del(mEvas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _canvas_focus_in_cb);
- evas_event_callback_del(mEvas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _canvas_focus_out_cb);
-
- evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_FOCUS_IN, _evas_object_focus_in_cb);
- evas_object_event_callback_del(mEvasImageObject, EVAS_CALLBACK_FOCUS_OUT, _evas_object_focus_out_cb);
-
- // evas object callbacks are deleted with the object
- evas_object_del(mEvasImageObject);
- mEvasImageObject = NULL;
- }
-}
-
-void EvasPlugin::CreateElmAccessObject(Evas_Object* parent)
-{
- // elm access register with image object
- mElmAccessObject = elm_access_object_register(mEvasImageObject, parent);
-
- // elm access action callbacks
- elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_HIGHLIGHT, _elm_access_highlight_cb, this);
- elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_UNHIGHLIGHT, _elm_access_unhighlight_cb, this);
- elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_HIGHLIGHT_NEXT, _elm_access_highlight_next_cb, this);
- elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_HIGHLIGHT_PREV, _elm_access_highlight_prev_cb, this);
- elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_ACTIVATE, _elm_access_activate_cb, this);
- elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_UP, _elm_access_value_up_cb, this);
- elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_DOWN, _elm_access_value_down_cb, this);
- elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_SCROLL, _elm_access_scroll_cb, this);
- elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_MOUSE, _elm_access_mouse_cb, this);
- elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_BACK, _elm_access_back_cb, this);
- elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_READ, _elm_access_read_cb, this);
- elm_access_action_cb_set(mElmAccessObject, ELM_ACCESS_ACTION_OVER, _elm_access_over_cb, this);
-
- /**
- * Dali doesn't set the order of elm focus chain.
- * Application should append mElmAccessObject to layout's custom focus chain
- *
- * e.g) elm_object_focus_custom_chain_append(parent, mElmAccessObject, NULL);
- */
-}
-
-void EvasPlugin::DeleteElmAccessObject()
-{
- if(mElmAccessObject)
- {
- // elm access action callbacks and elm_access_object will be deleted in unregister
- elm_access_object_unregister(mEvasImageObject);
- mElmAccessObject = NULL;
- }
-}
-
-void EvasPlugin::CreateElmFocusObject(Evas_Object* parent)
-{
- // create a button and set style as "focus", if does not want to show the focus, then "transparent"
- mElmFocusObject = elm_button_add(parent);
- // don't need to show the focus boundary here
- elm_object_style_set(mElmFocusObject, "transparent");
-
- // set the evas image object to focus object, but event should not be propagated
- elm_object_part_content_set(mElmFocusObject, "elm.swallow.content", mEvasImageObject);
- evas_object_propagate_events_set(mEvasImageObject, EINA_FALSE);
-
- // set the evas object you want to make focusable as the content of the swallow part
- evas_object_size_hint_weight_set(mElmFocusObject, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(mElmFocusObject, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- evas_object_smart_callback_add(mElmFocusObject, "focused", _elm_focus_object_focus_in_cb, this);
- evas_object_smart_callback_add(mElmFocusObject, "unfocused", _elm_focus_object_focus_out_cb, this);
-
- evas_object_show(mElmFocusObject);
-}
-
-void EvasPlugin::DeleteElmFocusObject()
-{
- if(mElmFocusObject)
- {
- evas_object_smart_callback_del(mElmFocusObject, "focused", _elm_focus_object_focus_in_cb);
- evas_object_smart_callback_del(mElmFocusObject, "unfocused", _elm_focus_object_focus_out_cb);
-
- evas_object_del(mElmFocusObject);
- mElmFocusObject = NULL;
- }
-}
-
-void EvasPlugin::CreateAdaptor(unsigned int initialWidth, unsigned int initialHeight)
-{
- mSurface = CreateSurface(initialWidth, initialHeight);
-
- mAdaptor = Internal::Adaptor::Adaptor::New( mSurface, DeviceLayout::DEFAULT_BASE_LAYOUT );
-
- Any surface = mSurface->GetSurface();
-
- Ecore_X_Pixmap pixmap = AnyCast<Ecore_X_Pixmap>(surface);
-
- /* set native pixmap surface */
- Evas_Native_Surface ns;
- ns.type = EVAS_NATIVE_SURFACE_X11;
- ns.version = EVAS_NATIVE_SURFACE_VERSION;
- ns.data.x11.pixmap = pixmap;
- ns.data.x11.visual = NULL;
-
- evas_object_image_native_surface_set(mEvasImageObject, &ns);
-}
-
-ECoreX::RenderSurface* EvasPlugin::CreateSurface( int width, int height )
-{
- PositionSize pixmapSize( 0, 0, width, height );
- Any surface;
- Any display;
- // if we already have surface, reuse its display
- if( mSurface )
- {
- display = mSurface->GetMainDisplay();
- }
-
- // create a X11 pixmap
- ECoreX::RenderSurface* daliSurface = ECoreX::CreatePixmapSurface( pixmapSize, surface, display, "no name", mIsTransparent );
-
- daliSurface->SetRenderNotification( mRenderNotification );
-
- return daliSurface;
-}
-
-void EvasPlugin::ResizeSurface()
-{
- // remember old surface
- Dali::RenderSurface* oldSurface = mSurface;
- mSurface = CreateSurface( mEvasImageObjectGeometry.width, mEvasImageObjectGeometry.height );
-
- // ask the replace the surface inside dali
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface( *mSurface ); // this method is synchronous => guarantee until rendering next frame
-
- // update the pixmap for evas
- {
- Any surface = mSurface->GetSurface();
- Ecore_X_Pixmap pixmap = AnyCast<Ecore_X_Pixmap>( surface );
-
- Evas_Native_Surface ns;
- ns.type = EVAS_NATIVE_SURFACE_X11;
- ns.version = EVAS_NATIVE_SURFACE_VERSION;
- ns.data.x11.pixmap = pixmap;
- ns.data.x11.visual = NULL;
-
- evas_object_image_native_surface_set(mEvasImageObject, &ns);
-
- // its now safe to delete the old surface
- delete oldSurface;
- }
-
- OnResize();
-}
-
-void EvasPlugin::ConnectEcoreEvent()
-{
- // Get Ecore_Evas using Evas.
- Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get( mEvas );
-
- if( ecoreEvas ) // Check invalid or valid.
- {
- // Get window from Ecore_Evas.
- Ecore_X_Window window = ecore_evas_gl_x11_window_get( ecoreEvas );
-
- // Set the application window at ime context.
- Dali::ImfManager imfManager = Dali::ImfManager::Get();
- Ecore_IMF_Context* imfContext = reinterpret_cast<Ecore_IMF_Context*>( imfManager.GetContext() );
- ecore_imf_context_client_window_set( imfContext, reinterpret_cast<void*>( window ) );
-
- if( window ) // Check invalid or valid.
- {
- // Connect clipboard events.
- mEcoreEventHandler.push_back( ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR, _ecore_x_event_selection_clear, this) );
- mEcoreEventHandler.push_back( ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, _ecore_x_event_selection_notify, this) );
-
- // Register Client message events - accessibility etc.
- mEcoreEventHandler.push_back( ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _ecore_x_event_client_message, this) );
- }
- }
-}
-
-void EvasPlugin::DisconnectEcoreEvent()
-{
- for( std::vector<Ecore_Event_Handler*>::iterator iter = mEcoreEventHandler.begin(), endIter = mEcoreEventHandler.end(); iter != endIter; ++iter )
- {
- ecore_event_handler_del( *iter );
- }
-
- mEcoreEventHandler.clear();
-}
-
-void EvasPlugin::Run()
-{
- if(mState == Ready)
- {
- // Run the adaptor
- mAdaptor->Start();
- mState = Running;
-
- OnInit();
- }
-}
-
-void EvasPlugin::Pause()
-{
- if(mState == Running)
- {
- mAdaptor->Pause();
- mState = Suspended;
-
- mPauseSignalV2.Emit( mEvasPlugin );
- }
-}
-
-void EvasPlugin::Resume()
-{
- if(mState == Suspended)
- {
- mAdaptor->Resume();
- mState = Running;
-
- mResumeSignalV2.Emit( mEvasPlugin );
- }
-
- // forcely dirty_set the evas_object on idle time
- ClearIdler();
- mEvasDirtyIdler = ecore_idler_add(_evas_object_dirty_set_idle_cb, this);
-}
-
-void EvasPlugin::ClearIdler(bool deleteHandle)
-{
- if(mEvasDirtyIdler)
- {
- if(deleteHandle)
- {
- ecore_idler_del(mEvasDirtyIdler);
- }
- mEvasDirtyIdler = NULL;
- }
-}
-
-void EvasPlugin::Stop()
-{
- if(mState != Stopped)
- {
- // Stop the adaptor
- mAdaptor->Stop();
- mState = Stopped;
-
- mTerminateSignalV2.Emit( mEvasPlugin );
- }
-}
-Evas_Object* EvasPlugin::GetEvasImageObject()
-{
- return mEvasImageObject;
-}
-
-Evas_Object* EvasPlugin::GetElmAccessObject()
-{
- return mElmAccessObject;
-}
-
-Evas_Object* EvasPlugin::GetElmFocusObject()
-{
- return mElmFocusObject;
-}
-
-void EvasPlugin::OnInit()
-{
- mInitialized = true;
-
- mInitSignalV2.Emit( mEvasPlugin );
-}
-
-void EvasPlugin::OnFirstRenderCompleted()
-{
- mFirstRenderCompletedSignalV2.Emit( mEvasPlugin );
-
- mFirstRenderCompleteNotified = true;
-}
-
-void EvasPlugin::Move()
-{
- Evas_Coord x, y, w, h;
- evas_object_geometry_get(mEvasImageObject, &x, &y, &w, &h);
-
- // update geometry
- mEvasImageObjectGeometry.x = x;
- mEvasImageObjectGeometry.y = y;
- mEvasImageObjectGeometry.width = w;
- mEvasImageObjectGeometry.height = h;
-
- DALI_LOG_INFO( gEvasPluginLogFilter, Debug::General, "EvasPlugin::Move : %d, %d, %d x %d\n", x, y, w, h );
-}
-
-void EvasPlugin::Resize()
-{
- Evas_Coord x, y, w, h;
- evas_object_geometry_get(mEvasImageObject, &x, &y, &w, &h);
-
- // skip meaningless resize signal
- if(w <= 1 || h <= 1)
- {
- return;
- }
-
- if(mEvasImageObjectGeometry.width == w && mEvasImageObjectGeometry.height == h)
- {
- return;
- }
-
- DALI_LOG_INFO( gEvasPluginLogFilter, Debug::General, "old size (%d x %d), new size (%d x %d)\n", mEvasImageObjectGeometry.width, mEvasImageObjectGeometry.height, w, h );
-
- // update geometry
- mEvasImageObjectGeometry.x = x;
- mEvasImageObjectGeometry.y = y;
- mEvasImageObjectGeometry.width = w;
- mEvasImageObjectGeometry.height = h;
-
- ResizeSurface();
-}
-
-void EvasPlugin::OnResize()
-{
- if(mInitialized)
- {
- // emit resized signal to application
- mResizeSignalV2.Emit( mEvasPlugin );
- }
-}
-
-void EvasPlugin::Render()
-{
- // dirty set while adaptor is running
- if( EvasPlugin::Running == mState )
- {
- /* dirty set to post the result of rendering via evas */
- evas_object_image_pixels_dirty_set( mEvasImageObject, EINA_TRUE );
- }
-}
-
-void EvasPlugin::OnTouchEvent(TouchPoint& point, int timeStamp)
-{
- if ( mAdaptor )
- {
- if(timeStamp < 1)
- {
- timeStamp = GetCurrentMilliSeconds();
- }
-
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).FeedTouchPoint( point, timeStamp );
- }
-}
-
-void EvasPlugin::OnKeyEvent(KeyEvent& keyEvent)
-{
- // Create KeyEvent and send to Core.
- if ( mAdaptor )
- {
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).FeedKeyEvent( keyEvent );
- }
-}
-
-void EvasPlugin::OnMouseWheelEvent(MouseWheelEvent& wheelEvent)
-{
- if ( mAdaptor )
- {
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).FeedWheelEvent( wheelEvent );
- }
-}
-
-void EvasPlugin::OnImfActivated(Dali::ImfManager& imfManager)
-{
- // When imf is activated, set focus to own evas-object to get key events
- evas_object_focus_set(mEvasImageObject, EINA_TRUE);
-}
-
-void EvasPlugin::RenderSync()
-{
- if( NULL != mAdaptor )
- {
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).RenderSync();
- }
-}
-
-bool EvasPlugin::OnAccessibilityActionEvent(Elm_Access_Action_Type actionType, Elm_Access_Action_Info* actionInfo, int x, int y)
-{
- bool ret = false;
-
- if( NULL == mAdaptor || NULL == actionInfo )
- {
- return ret;
- }
-
- Dali::AccessibilityManager accessibilityManager = Dali::AccessibilityManager::Get();
- if( accessibilityManager )
- {
- int touchType = actionInfo->mouse_type;
- int touchX = x >= 0 ? x : actionInfo->x;
- int touchY = y >= 0 ? y : actionInfo->y;
-
- switch(actionType)
- {
- case ELM_ACCESS_ACTION_HIGHLIGHT:
- case ELM_ACCESS_ACTION_READ:
- {
- ret = accessibilityManager.HandleActionReadEvent((unsigned int)x, (unsigned int)y, true);
- }
- break;
-
- case ELM_ACCESS_ACTION_OVER:
- {
- ret = accessibilityManager.HandleActionReadEvent((unsigned int)x, (unsigned int)y, false);
- }
- break;
-
- case ELM_ACCESS_ACTION_HIGHLIGHT_PREV:
- {
- // if actionInfo->highlight_end is true, need to handle end_of_list sound feedback
- ret = accessibilityManager.HandleActionPreviousEvent(actionInfo->highlight_end);
- if(!ret)
- {
- // when focus moving was failed, clear the focus
- accessibilityManager.HandleActionClearFocusEvent();
- }
- }
- break;
-
- case ELM_ACCESS_ACTION_HIGHLIGHT_NEXT:
- {
- // if actionInfo->highlight_end is true, need to handle end_of_list sound feedback
- ret = accessibilityManager.HandleActionNextEvent(actionInfo->highlight_end);
- if(!ret)
- {
- // when focus moving was failed, clear the focus
- accessibilityManager.HandleActionClearFocusEvent();
- }
- }
- break;
-
- case ELM_ACCESS_ACTION_ACTIVATE:
- {
- ret = accessibilityManager.HandleActionActivateEvent();
- }
- break;
-
- case ELM_ACCESS_ACTION_UNHIGHLIGHT:
- {
- ret = accessibilityManager.HandleActionClearFocusEvent();
- }
- break;
-
- case ELM_ACCESS_ACTION_SCROLL:
- {
- TouchPoint::State state(TouchPoint::Down);
-
- if (touchType == 0)
- {
- state = TouchPoint::Down; // mouse down
- }
- else if (touchType == 1)
- {
- state = TouchPoint::Motion; // mouse move
- }
- else if (touchType == 2)
- {
- state = TouchPoint::Up; // mouse up
- }
- else
- {
- state = TouchPoint::Interrupted; // error
- }
-
- // Send touch event to accessibility manager.
- TouchPoint point( 0, state, (float)touchX, (float)touchY );
- ret = accessibilityManager.HandleActionScrollEvent(point, GetCurrentMilliSeconds());
- }
- break;
-
- case ELM_ACCESS_ACTION_UP:
- {
- ret = accessibilityManager.HandleActionUpEvent();
- }
- break;
-
- case ELM_ACCESS_ACTION_DOWN:
- {
- ret = accessibilityManager.HandleActionDownEvent();
- }
- break;
-
- case ELM_ACCESS_ACTION_MOUSE:
- {
- // generate normal mouse event
- TouchPoint::State state(TouchPoint::Down);
-
- if (touchType == 0)
- {
- state = TouchPoint::Down; // mouse down
- }
- else if (touchType == 1)
- {
- state = TouchPoint::Motion; // mouse move
- }
- else if (touchType == 2)
- {
- state = TouchPoint::Up; // mouse up
- }
- else
- {
- state = TouchPoint::Interrupted; // error
- }
-
- // Send touch event to accessibility manager.
- TouchPoint point( 0, state, (float)touchX, (float)touchY );
- ret = accessibilityManager.HandleActionTouchEvent(point, GetCurrentMilliSeconds());
- }
- break;
-
- case ELM_ACCESS_ACTION_BACK:
- default:
- {
- DALI_LOG_WARNING("[%s:%d]\n", __FUNCTION__, __LINE__);
- }
-
- break;
- }
- }
- else
- {
- DALI_LOG_WARNING("[%s:%d]\n", __FUNCTION__, __LINE__);
- }
-
- DALI_LOG_INFO(gEvasPluginLogFilter, Debug::General, "[%s:%d] [action : %d] focus manager returns %s\n", __FUNCTION__, __LINE__, (int)(actionType), ret?"TRUE":"FALSE");
-
- return ret;
-
-}
-
-void EvasPlugin::OnEvasObjectFocusedIn()
-{
- if(mHasFocus)
- {
- return;
- }
- mHasFocus = true;
-
- // If the evas object gains focus and we hide the keyboard then show it again.
- if( Dali::Adaptor::IsAvailable() )
- {
- ConnectEcoreEvent();
-
- Dali::ImfManager imfManager( Dali::ImfManager::Get() );
- if( imfManager && imfManager.RestoreAfterFocusLost() )
- {
- imfManager.Activate();
- }
-
- // No need to connect callbacks as KeyboardStatusChanged will be called.
-
- // emit focused signal to application
- mFocusedSignalV2.Emit( mEvasPlugin );
- }
-}
-
-void EvasPlugin::OnEvasObjectFocusedOut()
-{
- if(!mHasFocus)
- {
- return;
- }
- mHasFocus = false;
-
- // If the evas object loses focus then hide the keyboard.
- if ( Dali::Adaptor::IsAvailable() )
- {
- Dali::ImfManager imfManager( Dali::ImfManager::Get() );
- if( imfManager && imfManager.RestoreAfterFocusLost() )
- {
- imfManager.Deactivate();
- }
-
- // Clipboard don't support that whether clipboard is shown or not. Hide clipboard.
- Dali::Clipboard clipboard = Dali::Clipboard::Get();
- clipboard.HideClipboard();
-
- DisconnectEcoreEvent();
-
- // emit unfocused signal to application
- mUnFocusedSignalV2.Emit( mEvasPlugin );
- }
-}
-
-void EvasPlugin::OnEcoreEventSelectionCleared( void* data, int type, void* event )
-{
- Ecore_X_Event_Selection_Clear* selectionClearEvent( (Ecore_X_Event_Selection_Clear*) event );
-
- if( selectionClearEvent->selection == ECORE_X_SELECTION_SECONDARY )
- {
- // Request to get the content from Ecore.
- ecore_x_selection_secondary_request(selectionClearEvent->win, ECORE_X_SELECTION_TARGET_TEXT);
- }
-}
-
-void EvasPlugin::OnEcoreEventSelectionNotified(void* data, int type, void* event)
-{
- Ecore_X_Event_Selection_Notify* selectionNotifyEvent( (Ecore_X_Event_Selection_Notify*) event );
-
- if( selectionNotifyEvent->selection == ECORE_X_SELECTION_SECONDARY )
- {
- // We have got the selected content, inform the clipboard event listener (if we have one).
- Dali::ClipboardEventNotifier clipboardEventNotifier = Dali::ClipboardEventNotifier::Get();
- Ecore_X_Selection_Data* selectionData( (Ecore_X_Selection_Data*) selectionNotifyEvent->data );
-
- if ( clipboardEventNotifier )
- {
- std::string content( (char*) selectionData->data, selectionData->length );
-
- if( !content.empty() )
- {
- clipboardEventNotifier.SetContent( content );
- clipboardEventNotifier.EmitContentSelectedSignal();
- }
- }
-
- // Claim the ownership of the SECONDARY selection.
- ecore_x_selection_secondary_set(selectionNotifyEvent->win, "", 1);
- }
-}
-
-void EvasPlugin::OnEcoreEventClientMessaged(void* data, int type, void* event)
-{
- Ecore_X_Event_Client_Message* clientMessageEvent( (Ecore_X_Event_Client_Message*)event );
-
- if(clientMessageEvent->message_type == ecore_x_atom_get(CLIPBOARD_ATOM))
- {
- std::string message(clientMessageEvent->data.b);
- if( message == CLIPBOARD_SET_OWNER_MESSAGE)
- {
- // Claim the ownership of the SECONDARY selection.
- ecore_x_selection_secondary_set(clientMessageEvent->win, "", 1);
-
- // Show the clipboard window
- Dali::Clipboard clipboard = Dali::Clipboard::Get();
- clipboard.ShowClipboard();
- }
- }
-}
-
-void EvasPlugin::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
-{
- mConnectionTracker.SignalConnected( slotObserver, callback );
-}
-
-void EvasPlugin::SignalDisconnected( SlotObserver* signal, CallbackBase* callback )
-{
- mConnectionTracker.SignalDisconnected( signal, callback );
-}
-
-std::size_t EvasPlugin::GetConnectionCount() const
-{
- return mConnectionTracker.GetConnectionCount();
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_EVAS_PLUGIN_H__
-#define __DALI_INTERNAL_EVAS_PLUGIN_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
-#include <boost/function.hpp>
-#include <boost/thread.hpp>
-#include <cstdlib>
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-#include <Elementary.h>
-#include <Evas.h>
-#include <Ecore.h>
-#include <Ecore_X.h>
-#include <Ecore_Input.h>
-
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/key-event-integ.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/common/imf-manager.h>
-#include <dali/public-api/adaptor-framework/evas-plugin.h>
-
-#include <internal/common/virtual-keyboard-impl.h>
-#include <internal/common/clipboard-impl.h>
-
-namespace Dali
-{
-
-class Adaptor;
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-class TriggerEvent;
-
-typedef Dali::Rect<int> PositionSize;
-
-namespace ECoreX
-{
-class RenderSurface;
-}
-
-/**
- * Implementation of the EvasPlugin class.
- */
-class EvasPlugin : public ConnectionTrackerInterface
-{
-public:
-
- typedef Dali::EvasPlugin::EvasPluginSignalV2 EvasPluginSignalV2;
-
- /**
- * Constructor
- * @param[in] evasPlugin The public instance of the EvasPlugin
- * @param[in] parent A pointer of the parent object
- * @param[in] isTransparent Whether the object is transparent or not
- * @param[in] initialWidth width for canvas
- * @param[in] initialHeight height for canvas
- */
- EvasPlugin(Dali::EvasPlugin& evasPlugin, Evas_Object* parent, bool isTransparent, unsigned int initialWidth, unsigned int initialHeight);
-
- /**
- * Destructor
- */
- virtual ~EvasPlugin();
-
-public:
-
- /**
- * @copydoc Dali::EvasPlugin::Start()
- */
- virtual void Run();
-
- /**
- * @copydoc Dali::EvasPlugin::Pause()
- */
- virtual void Pause();
-
- /**
- * @copydoc Dali::EvasPlugin::Resume()
- */
- virtual void Resume();
-
- /**
- * @copydoc Dali::EvasPlugin::Stop()
- */
- virtual void Stop();
-
- /**
- * @copydoc Dali::EvasPlugin::GetEvasImageObject()
- */
- Evas_Object* GetEvasImageObject();
-
- /**
- * @copydoc Dali::EvasPlugin::GetElmAccessObject()
- */
- Evas_Object* GetElmAccessObject();
-
- /**
- * @copydoc Dali::EvasPlugin::GetElmFocusObject()
- */
- Evas_Object* GetElmFocusObject();
-
- /**
- * @copydoc Dali::EvasPlugin::GetAdaptor()
- */
- Dali::Adaptor* GetAdaptor() { return mAdaptor;}
-
-public:
-
- /**
- * Called when the adaptor is initialised.
- */
- void OnInit();
-
- /**
- * Called to notify that Dali has started rendering and atleast one frame has been rendered
- */
- void OnFirstRenderCompleted();
-
- /**
- * Resize the surface, Called when evas_object_image resized
- */
- void Resize();
-
- /**
- * Move the surface, Called when evas_object_image moved
- */
- void Move();
-
- /**
- * Called when the rendering surface is resized
- */
- void OnResize();
-
- /**
- * Render the pixmap
- */
- void Render();
-
- /**
- * Called when the event dispatched in evas object area.
- * @param[in] point touch point structure
- * @param[in] timeStamp event timestamp, if it is less than 1, this function will generate current time stamp
- */
- void OnTouchEvent(TouchPoint& point, int timeStamp);
-
- /**
- * Called when the mouse wheel event dispatched in evas object area.
- * @param[in] wheelEvent The mouse wheel event
- */
- void OnMouseWheelEvent( MouseWheelEvent& wheelEvent );
-
- /**
- * Called when the key event dispatched in evas object area.
- * @param[in] keyEvent The key event.
- */
- void OnKeyEvent(KeyEvent& keyEvent);
-
- /**
- * Called when the accessibility action event dispatched from elm_access.
- * @param[in] actionType elm accessibility action type structure
- * @param[in] x x position for action, it could be unnecessary
- * @param[in] y y position for action, it could be unnecessary
- * @param[in] type mouse event type, it could be unnecessary
- * @return True if the event was handled
- */
- bool OnAccessibilityActionEvent(Elm_Access_Action_Type actionType, Elm_Access_Action_Info* actionInfo, int x = -1, int y = -1);
-
- /**
- * Called when evqas object gain focus.
- */
- void OnEvasObjectFocusedIn();
-
- /**
- * Called when evas object lost focus
- */
- void OnEvasObjectFocusedOut();
-
- /**
- * Called when the source window notifies us the content in clipboard is selected.
- * @param[in] data A data pointer.
- * @param[in] type A type of event.
- * @param[in] event A event information pointer.
- */
- void OnEcoreEventSelectionCleared(void* data, int type, void* event);
-
- /**
- * Called when the source window sends us about the selected content.
- * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
- * @param[in] data A data pointer.
- * @param[in] type A type of event.
- * @param[in] event A event information pointer.
- */
- void OnEcoreEventSelectionNotified(void* data, int type, void* event);
-
- /**
- * Called when the client messages (i.e. the accessibility events) are received.
- * @param[in] data A data pointer.
- * @param[in] type A type of event.
- * @param[in] event A event information pointer.
- */
- void OnEcoreEventClientMessaged(void* data, int type, void* event);
-
- /**
- * Called when the result of rendering was posted to on-screen.
- * Adaptor (i.e. render thread) can be waiting this sync to render next frame.
- */
- void RenderSync();
-
- /**
- * It returns geometry information of evas-object
- * @return geometry information of evas-object
- */
- PositionSize GetEvasObjectGeometry() const { return mEvasImageObjectGeometry; }
-
- /**
- * Clear ecore idler handler
- * @param[in] deleteHandle false if it does not need to delete the idler handle
- * (e.g. when idler callback returns ECORE_CALLBACK_CANCEL, handler will be deleted automatically)
- */
- void ClearIdler(bool deleteHandle = true);
-
- /**
- * @copydoc ConnectionTrackerInterface::SignalConnected
- */
- virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback );
-
- /**
- * @copydoc ConnectionTrackerInterface::SignalDisconnected
- */
- virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback );
-
- /**
- * @copydoc ConnectionTrackerInterface::GetConnectionCount
- */
- virtual std::size_t GetConnectionCount() const;
-
-public: // Signals
-
- /**
- * @copydoc Dali::EvasPlugin::InitSignal()
- */
- EvasPluginSignalV2& InitSignal() { return mInitSignalV2; }
-
- /**
- * @copydoc Dali::EvasPlugin::FirstRenderCompletedSignal()
- */
- EvasPluginSignalV2& FirstRenderCompletedSignal() { return mFirstRenderCompletedSignalV2; }
-
- /**
- * @copydoc Dali::EvasPlugin::TerminateSignal()
- */
- EvasPluginSignalV2& TerminateSignal() { return mTerminateSignalV2; }
-
- /**
- * @copydoc Dali::EvasPlugin::PauseSignal()
- */
- EvasPluginSignalV2& PauseSignal() { return mPauseSignalV2; }
-
- /**
- * @copydoc Dali::EvasPlugin::ResumeSignal()
- */
- EvasPluginSignalV2& ResumeSignal() { return mResumeSignalV2; }
-
- /**
- * @copydoc Dali::EvasPlugin::ResizeSignal()
- */
- EvasPluginSignalV2& ResizeSignal() { return mResizeSignalV2; }
-
- /**
- * @copydoc Dali::EvasPlugin::FocusedSignal()
- */
- EvasPluginSignalV2& FocusedSignal() { return mFocusedSignalV2; }
-
- /**
- * @copydoc Dali::EvasPlugin::UnFocusedSignal()
- */
- EvasPluginSignalV2& UnFocusedSignal() { return mUnFocusedSignalV2; }
-
-private:
-
- // Undefined
- EvasPlugin(const EvasPlugin&);
- EvasPlugin& operator=(EvasPlugin&);
-
-private:
-
- /**
- * Create / Delete the evas image object
- */
- void CreateEvasImageObject(Evas* evas, unsigned int initialWidth, unsigned int initialHeight, bool isTransparent);
- void DeleteEvasImageObject();
-
- /**
- * Create / Delete the elm access object
- */
- void CreateElmAccessObject(Evas_Object* parent);
- void DeleteElmAccessObject();
-
- /**
- * Create / Delete the elm focus object
- */
- void CreateElmFocusObject(Evas_Object* parent);
- void DeleteElmFocusObject();
-
- /**
- * Creates the adaptor
- */
- void CreateAdaptor(unsigned int initialWidth, unsigned int initialHeight);
-
- /**
- * Creates the render surface
- * @param width of the surface
- * @param height of the surface
- * @return the new surface
- */
- ECoreX::RenderSurface* CreateSurface( int width, int height );
-
- /**
- * Resize the surface
- * To resize, create new surface with evas object's size and replace with it.
- */
- void ResizeSurface();
-
- /**
- * Connect ecore event if the evas plugin has Ecore_X_Window.
- */
- void ConnectEcoreEvent();
-
- /**
- * Disconnect all connected event.
- */
- void DisconnectEcoreEvent();
-
- /**
- * For ImfActivated signal
- * When the imf is activated, it will handle the focus
- * @param[in] imfManager imfManager instance
- */
- void OnImfActivated(Dali::ImfManager& imfManager);
-
-public:
- enum State
- {
- Ready,
- Running,
- Suspended,
- Stopped,
- };
-
- State mState;
-
-public:
- /* for rendering control : these public members will be used in static function */
- Evas_Object* mEvasImageObject;
- Evas_Object* mElmAccessObject;
- Evas_Object* mElmFocusObject;
- ECoreX::RenderSurface* mSurface;
- bool mFirstRenderCompleteNotified;
-
-private:
-
- EvasPluginSignalV2 mInitSignalV2;
- EvasPluginSignalV2 mFirstRenderCompletedSignalV2;
- EvasPluginSignalV2 mTerminateSignalV2;
- EvasPluginSignalV2 mPauseSignalV2;
- EvasPluginSignalV2 mResumeSignalV2;
- EvasPluginSignalV2 mResizeSignalV2;
- EvasPluginSignalV2 mFocusedSignalV2;
- EvasPluginSignalV2 mUnFocusedSignalV2;
-
- Dali::EvasPlugin& mEvasPlugin;
-
- Dali::Adaptor* mAdaptor;
-
- Evas* mEvas;
- PositionSize mEvasImageObjectGeometry;
-
- bool mInitialized;
- bool mIsTransparent;
- bool mHasFocus;
- TriggerEvent* mRenderNotification; ///< Render Notification trigger
-
- Ecore_Idler * mEvasDirtyIdler; ///< Ecore idler for updating image object when it resumed
-
- std::vector<Ecore_Event_Handler*> mEcoreEventHandler; ///< Vector of Ecore_Event_Handler
-
- Dali::ConnectionTracker mConnectionTracker; ///< Used to implement ConnectionTrackerInterface
-
-public:
- inline static EvasPlugin& GetImplementation(Dali::EvasPlugin& evasPlugin) { return *evasPlugin.mImpl; }
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_EVAS_PLUGIN_H__
+++ /dev/null
-# mobile profile internal files
-tizen_adaptor_internal_common_src_files += \
- $(tizen_adaptor_internal_src_dir)/key-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/../mobile/mobile-render-surface-factory.cpp \
- $(tizen_adaptor_internal_src_dir)/../mobile/mobile-native-buffer-render-surface.cpp \
- $(tizen_adaptor_internal_src_dir)/../mobile/mobile-system-settings.cpp \
- $(tizen_adaptor_internal_src_dir)/../mobile/mobile-color-controller-impl.cpp
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <internal/common/color-controller-impl.h>
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/object/type-registry.h>
-#include <efl_assist_theme.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-
-BaseHandle Create()
-{
- return ColorController::Get();
-}
-Dali::TypeRegistration COLOR_CONTROLLER_TYPE( typeid(Dali::ColorController), typeid(Dali::BaseHandle), Create );
-
-}
-
-Dali::ColorController ColorController::Get()
-{
- Dali::ColorController colorController;
-
- if ( Adaptor::IsAvailable() )
- {
- // Check whether the singleton is already created
- Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::ColorController ) );
- if(handle)
- {
- // If so, downcast the handle
- colorController = Dali::ColorController( dynamic_cast< ColorController* >( handle.GetObjectPtr() ) );
- }
- else
- {
- Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
- colorController = Dali::ColorController( new ColorController( ) );
- adaptorImpl.RegisterSingleton( typeid( colorController ), colorController );
- }
- }
-
- return colorController;
-
-}
-
-ColorController::ColorController()
-{
-}
-
-ColorController::~ColorController()
-{
-}
-
-bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
-{
- int R = 0;
- int G = 0;
- int B = 0;
- int A = 0;
-
- if( ea_theme_color_get(colorCode.c_str(), &R, &G, &B, &A, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) )
- {
- colorValue.r = (float) (R) / 255.0f;
- colorValue.g = (float) (G) / 255.0f;
- colorValue.b = (float) (B) / 255.0f;
- colorValue.a = (float) (A) / 255.0f;
-
- return true;
- }
-
- return false;
-}
-
-bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
-{
- int R = 0;
- int G = 0;
- int B = 0;
- int A = 0;
-
- int outlineR = 0;
- int outlineG = 0;
- int outlineB = 0;
- int outlineA = 0;
-
- int shadowR = 0;
- int shadowG = 0;
- int shadowB = 0;
- int shadowA = 0;
-
- if( ea_theme_color_get(colorCode.c_str(), &R, &G, &B, &A, &outlineR, &outlineG, &outlineB, &outlineA, &shadowR, &shadowG, &shadowB, &shadowA) )
- {
- textColor.r = (float) (R) / 255.0f;
- textColor.g = (float) (G) / 255.0f;
- textColor.b = (float) (B) / 255.0f;
- textColor.a = (float) (A) / 255.0f;
-
- textOutlineColor.r = (float) (outlineR) / 255.0f;
- textOutlineColor.g = (float) (outlineG) / 255.0f;
- textOutlineColor.b = (float) (outlineB) / 255.0f;
- textOutlineColor.a = (float) (outlineA) / 255.0f;
-
- textShadowColor.r = (float) (shadowR) / 255.0f;
- textShadowColor.g = (float) (shadowG) / 255.0f;
- textShadowColor.b = (float) (shadowB) / 255.0f;
- textShadowColor.a = (float) (shadowA) / 255.0f;
-
- return true;
- }
-
- return false;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "mobile-native-buffer-render-surface.h"
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-#include <dali/integration-api/gl-abstraction.h>
-#include <native-buffer-pool.h>
-
-// INTERANL INCLUDES
-#include <internal/common/gl/egl-implementation.h>
-#include <internal/common/trigger-event.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-#if defined(DEBUG_ENABLED)
-extern Debug::Filter* gRenderSurfaceLogFilter;
-#endif
-
-namespace ECoreX
-{
-
-NativeBufferRenderSurface::NativeBufferRenderSurface( native_buffer_provider* provider,
- native_buffer_pool* pool,
- unsigned int maxBufferCount,
- Dali::PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent )
-: RenderSurface( Dali::RenderSurface::NATIVE_BUFFER, positionSize, surface, display, "native_buffer", isTransparent ),
- mProvider( provider ),
- mPool( pool ),
- mMaxBufferCount( maxBufferCount ),
- mIsAcquired( false )
-{
- DALI_ASSERT_ALWAYS(maxBufferCount > 0);
- Init( surface );
-}
-
-NativeBufferRenderSurface::~NativeBufferRenderSurface()
-{
- DALI_LOG_WARNING("%d native buffer will be destroyed\n", mBuffers.size());
-
- // destroy buffers
- NativeBufferContainer::iterator bufferIter;
- for (bufferIter = mBuffers.begin(); bufferIter != mBuffers.end(); ++bufferIter)
- {
- native_buffer_destroy((*bufferIter));
- }
- mBuffers.clear();
-}
-
-Ecore_X_Drawable NativeBufferRenderSurface::GetDrawable()
-{
- return (Ecore_X_Drawable)0;
-}
-
-Dali::RenderSurface::SurfaceType NativeBufferRenderSurface::GetType()
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
- return Dali::RenderSurface::NATIVE_BUFFER;
-}
-
-Any NativeBufferRenderSurface::GetSurface()
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
- return Any();
-}
-
-void NativeBufferRenderSurface::InitializeEgl( EglInterface& egl )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );
- eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ), false /* external surface */);
-
- eglImpl.ChooseConfig(false, mColorDepth);
-}
-
-native_buffer* NativeBufferRenderSurface::CreateNativeBuffer()
-{
- native_buffer* buffer;
-
- buffer = native_buffer_create(mProvider, mPosition.width, mPosition.height,
- mColorDepth == COLOR_DEPTH_32? mPosition.width * 4 : mPosition.width * 3, /* stride will be deprecated */
- mColorDepth == COLOR_DEPTH_32? NATIVE_BUFFER_FORMAT_BGRA_8888 : NATIVE_BUFFER_FORMAT_RGB_888,
- NATIVE_BUFFER_USAGE_3D_RENDER);
-
- if(buffer)
- {
- // insert buffer to list
- mBuffers.push_back(buffer);
- }
-
- return buffer;
-}
-
-void NativeBufferRenderSurface::CreateEglSurface( EglInterface& egl )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );
-
- // create one buffer
- native_buffer_pool_add_buffer(mPool, CreateNativeBuffer());
-
- DALI_ASSERT_ALWAYS( native_buffer_pool_acquire_surface( mPool, eglImpl.GetDisplay(), eglImpl.GetContext() ) == STATUS_SUCCESS );
- mIsAcquired = true;
-}
-
-void NativeBufferRenderSurface::DestroyEglSurface( EglInterface& egl )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- // Remove buffers from pool
- native_buffer_pool_reset(mPool);
-}
-
-bool NativeBufferRenderSurface::ReplaceEGLSurface( EglInterface& egl )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- return false;
-}
-
-bool NativeBufferRenderSurface::PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction )
-{
- EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );
-
- if(mIsAcquired)
- {
- mIsAcquired = false;
- return true;
- }
-
- // Attempt to acquire a surface for rendering
- while( !mIsStopped && native_buffer_pool_get_input_buffer_count(mPool) < 1 )
- {
- if(mBuffers.size() <= mMaxBufferCount)
- {
- // create one buffer
- native_buffer_pool_add_buffer(mPool, CreateNativeBuffer());
- }
- else
- {
- usleep( 5 * 1000 ); // polling per 5 msec
- }
- }
-
- if( !mIsStopped && native_buffer_pool_acquire_surface( mPool, eglImpl.GetDisplay(), eglImpl.GetContext() ) != STATUS_SUCCESS )
- {
- DALI_LOG_ERROR("Failed to acquire native buffer surface (# queue : %d)\n", native_buffer_pool_get_input_buffer_count(mPool));
- }
-
- return !mIsStopped; // fail if it is stopped
-}
-
-void NativeBufferRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode )
-{
- glAbstraction.Flush();
-
- // release the surface to allow consumer usage
- if(native_buffer_pool_release_surface( mPool ) != STATUS_SUCCESS)
- {
- DALI_LOG_ERROR("Failed to release native buffer surface (# queue : %d)\n", native_buffer_pool_get_input_buffer_count(mPool));
- }
-
- // create damage for client applications which wish to know the update timing
- if( mRenderNotification )
- {
- // use notification trigger
- // Tell the event-thread to render the pixmap
- mRenderNotification->Trigger();
- }
-
- // Do render synchronisation
- DoRenderSync( timeDelta, syncMode );
-}
-
-void NativeBufferRenderSurface::CreateXRenderable()
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- // nothing to do
-}
-
-void NativeBufferRenderSurface::UseExistingRenderable( unsigned int surfaceId )
-{
- DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
-
- // nothing to do
-}
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_NATIVE_BUFFER_RENDER_SURFACE_H__
-#define __DALI_INTERNAL_NATIVE_BUFFER_RENDER_SURFACE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <native-buffer-pool.h>
-#include <dali/public-api/common/vector-wrapper.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/ecore-x/ecore-x-render-surface.h>
-
-using namespace std;
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace ECoreX
-{
-
-/**
- * NativeBuffer API compatible implementation of RenderSurface.
- */
-class NativeBufferRenderSurface : public RenderSurface
-{
-public:
-
- /**
- * Constructor
- */
- NativeBufferRenderSurface( native_buffer_provider* provider,
- native_buffer_pool* pool,
- unsigned int maxBufferCount,
- Dali::PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent );
-
- /**
- * Destructor
- */
- virtual ~NativeBufferRenderSurface();
-
-public: // API
-
- /**
- * @copydoc Dali::Internal::Adaptor::ECoreX::RenderSurface::GetDrawable()
- */
- virtual Ecore_X_Drawable GetDrawable();
-
-public: // from Dali::RenderSurface
-
- /**
- * @copydoc Dali::RenderSurface::GetType()
- */
- virtual Dali::RenderSurface::SurfaceType GetType();
-
- /**
- * @copydoc Dali::RenderSurface::GetSurface()
- */
- virtual Any GetSurface();
-
-public: // from Internal::Adaptor::RenderSurface
-
- /// @copydoc Dali::Internal::Adaptor::RenderSurface::InitializeEgl
- virtual void InitializeEgl( EglInterface& egl );
-
- /// @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface
- virtual void CreateEglSurface( EglInterface& egl );
-
- /// @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface
- virtual void DestroyEglSurface( EglInterface& egl );
-
- /// @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface
- virtual bool ReplaceEGLSurface( EglInterface& egl );
-
- /// @copydoc Dali::RenderSurface::PreRender
- virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction );
-
- /// @copydoc Dali::RenderSurface::PostRender
- virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode );
-
-protected:
-
- /**
- * Create XWindow
- */
- virtual void CreateXRenderable();
-
- /**
- * @copydoc Dali::Internal::Adaptor::ECoreX::RenderSurface::UseExistingRenderable
- */
- virtual void UseExistingRenderable( unsigned int surfaceId );
-
-private:
- /**
- * Create native buffer
- */
- native_buffer* CreateNativeBuffer();
-
-private: // Data
- native_buffer_provider* mProvider;
- native_buffer_pool* mPool;
-
- typedef std::vector<native_buffer*> NativeBufferContainer;
- NativeBufferContainer mBuffers;
-
- unsigned int mMaxBufferCount;
- bool mIsAcquired;
-}; // class NativeBufferRenderSurface
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_NATIVE_BUFFER_RENDER_SURFACE_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <internal/common/ecore-x/pixmap-render-surface.h>
-#include "mobile-native-buffer-render-surface.h"
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace ECoreX
-{
-
-DALI_EXPORT_API RenderSurface* CreatePixmapSurface(
- PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent )
-{
- return new PixmapRenderSurface( positionSize, surface, display, name, isTransparent );
-}
-
-DALI_EXPORT_API RenderSurface* CreateNativeBufferSurface(
- native_buffer_provider* provider,
- native_buffer_pool* pool,
- unsigned int maxBufferCount,
- PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent )
-{
- return new NativeBufferRenderSurface( provider, pool, maxBufferCount, positionSize,
- surface, display, name, isTransparent);
-}
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-
-
+++ /dev/null
-#ifndef __DALI_INTERNAL_ADAPTOR_MOBILE_RENDER_SURFACE_FACTORY_H__
-#define __DALI_INTERNAL_ADAPTOR_MOBILE_RENDER_SURFACE_FACTORY_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <boost/any.hpp>
-#include <string>
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/common/dali-common.h>
-
-// INTERNAL INCLUDES
-#include <native-buffer-pool.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace ECoreX
-{
-
-class RenderSurface;
-
-/**
- * Surface factory function for pixmap
- * A pixmap surface is created.
- *
- * @param [in] type the type of surface to create
- * @param [in] positionSize the position and size of the surface to create
- * @param [in] display X Pixmap to use, or null for default.
- * @param [in] display X Display to use, or null for default.
- * @param [in] name Name of surface passed in
- * @param [in] isTransparent Whether the surface has an alpha channel
- */
-DALI_IMPORT_API RenderSurface* CreatePixmapSurface(
- PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent );
-
-/**
- * Surface factory function for Native buffer
- * A native buffer surface is created.
- * @param [in] provider The provider
- * @param [in] pool The native buffer pool
- * @param [in] maxBufferCount The maximum number of buffers to create
- * @param [in] type the type of surface to create
- * @param [in] positionSize the position and size of the surface to create
- * @param [in] display X Pixmap to use, or null for default.
- * @param [in] display X Display to use, or null for default.
- * @param [in] name Name of surface passed in
- * @param [in] isTransparent Whether the surface has an alpha channel
- */
-DALI_IMPORT_API RenderSurface* CreateNativeBufferSurface(
- native_buffer_provider* provider,
- native_buffer_pool* pool,
- unsigned int maxBufferCount,
- PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent );
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ADAPTOR_MOBILE_RENDER_SURFACE_FACTORY_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <system_settings.h>
-#include <Elementary.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/system-settings.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-int GetLongPressTime( int defaultTime )
-{
- int delay( 0 );
-
- // read system setting
- if( SYSTEM_SETTINGS_ERROR_NONE != system_settings_get_value_int(SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, &delay ) )
- {
- // on error, return default
- delay = defaultTime;
- }
-
- return delay;
-}
-
-int GetElmAccessActionOver()
-{
- return ELM_ACCESS_ACTION_OVER;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "native-buffer-plugin-impl.h"
-
-// EXTERNAL HEADERS
-#include <Ecore_X.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL HEADERS
-#include <internal/common/accessibility-manager-impl.h>
-#include <internal/common/adaptor-impl.h>
-#include "mobile-render-surface-factory.h"
-#include <internal/common/ecore-x/ecore-x-render-surface.h>
-#include <internal/common/trigger-event.h>
-
-namespace Dali
-{
-
-namespace SlpPlatform
-{
-
-class SlpPlatformAbstraction;
-
-} // namespace SlpPlatform
-
-namespace Integration
-{
-
-class Core;
-
-} // namespace Integration
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace
-{
-
-#if defined(DEBUG_ENABLED)
-Integration::Log::Filter* gLogFilter = Integration::Log::Filter::New(Debug::Verbose, true, "LOG_NATIVE_BUFFER_PLUGIN");
-#endif
-
-} // namespace
-
-NativeBufferPlugin::NativeBufferPlugin(Dali::NativeBufferPlugin& nbPlugin, unsigned int initialWidth, unsigned int initialHeight, bool isTransparent, unsigned int maxBufferCount, Dali::RenderSurface::RenderMode mode, const DeviceLayout& baseLayout )
-: mNativeBufferPlugin( nbPlugin ),
- mAdaptor( NULL ),
- mSurface( NULL ),
- mRenderNotification( NULL ),
- mState( Stopped ),
- mInitialized( false ),
- mFirstRenderCompleteNotified( false )
-{
- // create provider
- mProvider = native_buffer_provider_create(NATIVE_BUFFER_PROVIDER_CORE);
-
- //create pool
- mPool = native_buffer_pool_create( mProvider );
-
- // create surface
- mSurface = CreateSurface( initialWidth, initialHeight, isTransparent, maxBufferCount );
-
- // create adaptor
- CreateAdaptor( *mSurface, baseLayout );
-
- // render notification
- mRenderNotification = new TriggerEvent( boost::bind(&NativeBufferPlugin::OnRender, this ) );
- mSurface->SetRenderNotification( mRenderNotification );
- mSurface->SetRenderMode(mode);
-
- mState = Ready;
-}
-
-NativeBufferPlugin::~NativeBufferPlugin()
-{
- if( mAdaptor )
- {
- Stop();
-
- // no more notifications
- delete mRenderNotification;
-
- delete mAdaptor;
- delete mSurface;
-
- native_buffer_pool_destroy(mPool);
- native_buffer_provider_destroy(mProvider);
- }
-}
-
-void NativeBufferPlugin::CreateAdaptor( ECoreX::RenderSurface &surface, const DeviceLayout& baseLayout )
-{
- DALI_LOG_TRACE_METHOD( gLogFilter );
-
- mAdaptor = Internal::Adaptor::Adaptor::New( &surface, baseLayout );
-}
-
-ECoreX::RenderSurface* NativeBufferPlugin::CreateSurface( int width, int height, bool isTransparent, unsigned int maxBufferCount )
-{
- DALI_LOG_TRACE_METHOD( gLogFilter );
-
- PositionSize positionSize( 0, 0, width, height );
- Any surface;
- Any display;
-
- // if we already have surface, reuse its display
- if( mSurface )
- {
- display = mSurface->GetMainDisplay();
- }
-
- ECoreX::RenderSurface* nbSurface = ECoreX::CreateNativeBufferSurface( mProvider, mPool, maxBufferCount, positionSize, surface, display, "no name", isTransparent );
-
- return nbSurface;
-}
-
-void NativeBufferPlugin::ChangeSurfaceSize(unsigned int width, unsigned int height)
-{
- // TODO: not yet implemented
- DALI_LOG_WARNING("Not yet implemented!\n");
-}
-
-Vector2 NativeBufferPlugin::GetBufferCount()
-{
- Vector2 retVal;
- retVal.x = native_buffer_pool_get_input_buffer_count(mPool);
- retVal.y = native_buffer_pool_get_output_buffer_count(mPool);
-
- return retVal;
-}
-
-void NativeBufferPlugin::Run()
-{
- DALI_LOG_TRACE_METHOD( gLogFilter );
-
- if(mState == Ready)
- {
- // Run the adaptor
- mAdaptor->Start();
- mState = Running;
-
- OnInit();
- }
-}
-
-void NativeBufferPlugin::Pause()
-{
- DALI_LOG_TRACE_METHOD( gLogFilter );
-
- if(mState == Running)
- {
- mAdaptor->Pause();
- mState = Suspended;
-
- mPauseSignalV2.Emit( mNativeBufferPlugin );
- }
-}
-
-void NativeBufferPlugin::Resume()
-{
- DALI_LOG_TRACE_METHOD( gLogFilter );
-
- if(mState == Suspended)
- {
- mAdaptor->Resume();
- mState = Running;
-
- mResumeSignalV2.Emit( mNativeBufferPlugin );
- }
-}
-
-void NativeBufferPlugin::Stop()
-{
- DALI_LOG_TRACE_METHOD( gLogFilter );
-
- if(mState != Stopped)
- {
- // Stop the adaptor
- mAdaptor->Stop();
- mState = Stopped;
-
- mTerminateSignalV2.Emit( mNativeBufferPlugin );
- }
-}
-
-void NativeBufferPlugin::OnInit()
-{
- DALI_LOG_TRACE_METHOD( gLogFilter );
-
- mInitialized = true;
- mInitSignalV2.Emit( mNativeBufferPlugin );
-}
-
-/*
- * app can poll the get buffer after first rendered signal
- * Otherwise, app can get render signal whenever it rendered
- */
-void NativeBufferPlugin::OnFirstRenderCompleted()
-{
- DALI_LOG_TRACE_METHOD( gLogFilter );
-
- mFirstRenderCompletedSignalV2.Emit( mNativeBufferPlugin );
- mFirstRenderCompleteNotified = true;
-}
-
-/*
- * app can poll the get buffer after first rendered signal
- * Otherwise, app can get render signal whenever it rendered
- */
-void NativeBufferPlugin::OnRender()
-{
- // dirty set while adaptor is running
- if( Running == mState )
- {
- mRenderSignalV2.Emit( mNativeBufferPlugin );
- }
-}
-
-// TODO: need it?
-void NativeBufferPlugin::RenderSync()
-{
- if( NULL != mAdaptor )
- {
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).RenderSync();
- }
-}
-
-native_buffer* NativeBufferPlugin::GetNativeBufferFromOutput()
-{
- return native_buffer_pool_get_buffer(mPool);
-}
-
-bool NativeBufferPlugin::AddNativeBufferToInput(native_buffer* nativeBuffer)
-{
- status_t result = native_buffer_pool_add_buffer(mPool, nativeBuffer);
-
- if(result != STATUS_SUCCESS)
- {
- DALI_LOG_WARNING("native_buffer_pool_add_buffer returns %d\n", result);
- return false;
- }
-
- return true;
-}
-
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_NATIVE_BUFFER_PLUGIN_IMPL_H__
-#define __DALI_INTERNAL_NATIVE_BUFFER_PLUGIN_IMPL_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <native-buffer-pool.h>
-#include <boost/bind.hpp>
-
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-
-// INTERNAL INCLUDES
-
-#include <dali/public-api/adaptor-framework/native-buffer-plugin.h>
-
-namespace Dali
-{
-
-class Adaptor;
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-class TriggerEvent;
-
-typedef Dali::Rect<int> PositionSize;
-
-namespace ECoreX
-{
-
-class RenderSurface;
-
-}
-
-/**
- * Implementation of the NativeBufferPlugin class.
- */
-class NativeBufferPlugin
-{
-public:
-
- typedef Dali::NativeBufferPlugin::NativeBufferPluginSignalV2 NativeBufferPluginSignalV2;
-
- /**
- * Constructor
- * @param[in] nbPlugin The public instance of the NativeBufferPlugin
- * @param[in] nbPool A pointer to a native_buffer_pool object
- * @param[in] initialWidth The initial width of the plugin and DALis stage
- * @param[in] initialWidth The initial height of the plugin and DALis stage
- * @param[in] mode The rendering mode to decide frame rate
- */
- NativeBufferPlugin( Dali::NativeBufferPlugin& nbPlugin,
- unsigned int initialWidth,
- unsigned int initialHeight,
- bool isTransparent,
- unsigned int maxBufferCount,
- RenderSurface::RenderMode mode,
- const DeviceLayout& baseLayout);
-
- /**
- * Destructor
- */
- virtual ~NativeBufferPlugin();
-
-public:
-
- /**
- * @copydoc Dali::NativeBufferPlugin::Run()
- */
- virtual void Run();
-
- /**
- * @copydoc Dali::NativeBufferPlugin::Pause()
- */
- virtual void Pause();
-
- /**
- * @copydoc Dali::NativeBufferPlugin::Resume()
- */
- virtual void Resume();
-
- /**
- * @copydoc Dali::NativeBufferPlugin::Stop()
- */
- virtual void Stop();
-
- /**
- * @copydoc Dali::NativeBufferPlugin::GetNativeBufferFromOutput()
- */
- native_buffer* GetNativeBufferFromOutput();
-
- /**
- * @copydoc Dali::NativeBufferPlugin::AddNativeBufferToInput()
- */
- bool AddNativeBufferToInput(native_buffer* nativeBuffer);
-
- /**
- * @copydoc Dali::NativeBufferPlugin::ChangeSurfaceSize()
- */
- void ChangeSurfaceSize(unsigned int width, unsigned int height);
-
- /**
- * @copydoc Dali::NativeBufferPlugin::GetBufferCount()
- */
- Vector2 GetBufferCount();
-
- /**
- * @copydoc Dali::NativeBufferPlugin::GetAdaptor()
- */
- Dali::Adaptor* GetAdaptor()
- {
- return mAdaptor;
- }
-
-public:
-
- /**
- * Called when the adaptor is initialised.
- */
- void OnInit();
-
- /**
- * Called when the result of rendering was posted to on-screen.
- * Adaptor (i.e. render thread) can be waiting this sync to render next frame.
- */
- void RenderSync();
-
- /**
- * Called to notify that Dali has started rendering and atleast one frame has been rendered
- */
- void OnFirstRenderCompleted();
-
- /**
- * Called to notify that Dali has rendered one frame
- */
- void OnRender();
-
-public: // Signals
-
- /**
- * @copydoc Dali::NativeBufferPlugin::InitSignal()
- */
- NativeBufferPluginSignalV2& InitSignal()
- {
- return mInitSignalV2;
- }
-
- /**
- * @copydoc Dali::NativeBufferPlugin::TerminateSignal()
- */
- NativeBufferPluginSignalV2& TerminateSignal()
- {
- return mTerminateSignalV2;
- }
-
- /**
- * @copydoc Dali::NativeBufferPlugin::PauseSignal()
- */
- NativeBufferPluginSignalV2& PauseSignal()
- {
- return mPauseSignalV2;
- }
-
- /**
- * @copydoc Dali::NativeBufferPlugin::ResumeSignal()
- */
- NativeBufferPluginSignalV2& ResumeSignal()
- {
- return mResumeSignalV2;
- }
-
- /**
- * @copydoc Dali::NativeBufferPlugin::FirstRenderCompletedSignal()
- */
- NativeBufferPluginSignalV2& FirstRenderCompletedSignal()
- {
- return mFirstRenderCompletedSignalV2;
- }
-
- /**
- * @copydoc Dali::NativeBufferPlugin::RenderSignal()
- */
- NativeBufferPluginSignalV2& RenderSignal()
- {
- return mRenderSignalV2;
- }
-
-private:
-
- // Undefined copy constructor
- NativeBufferPlugin(const NativeBufferPlugin&);
-
- // Undefined assignment operator
- NativeBufferPlugin& operator=(NativeBufferPlugin&);
-
-private:
-
- /**
- * Create the adaptor
- */
- void CreateAdaptor( ECoreX::RenderSurface &surface, const DeviceLayout& baseLayout );
-
- /**
- * Creates a render surface
- * @param[in] width Width of the surface
- * @param[in] height Height of the surface
- * @param[in] isTransparent Whether the surface is transparent
- * @return A pointer to the new surface
- */
- ECoreX::RenderSurface* CreateSurface( int width, int height, bool isTransparent, unsigned int maxBufferCount );
-
-public:
-
- enum State
- {
- Ready,
- Running,
- Suspended,
- Stopped,
- };
-
-
-private:
-
- // Signals
- NativeBufferPluginSignalV2 mInitSignalV2;
- NativeBufferPluginSignalV2 mTerminateSignalV2;
- NativeBufferPluginSignalV2 mPauseSignalV2;
- NativeBufferPluginSignalV2 mResumeSignalV2;
- NativeBufferPluginSignalV2 mResetSignalV2;
- NativeBufferPluginSignalV2 mFirstRenderCompletedSignalV2;
- NativeBufferPluginSignalV2 mRenderSignalV2;
-
- Dali::NativeBufferPlugin& mNativeBufferPlugin;
- native_buffer_provider* mProvider;
- native_buffer_pool* mPool;
- Dali::Adaptor* mAdaptor;
- ECoreX::RenderSurface* mSurface;
- TriggerEvent* mRenderNotification; ///< Render Notification trigger
- State mState;
- bool mInitialized;
- bool mFirstRenderCompleteNotified;
-
-public:
-
- inline static NativeBufferPlugin& GetImplementation(Dali::NativeBufferPlugin& nbPlugin)
- {
- return *nbPlugin.mImpl;
- }
-
-}; // class NativeBufferPlugin
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_NATIVE_BUFFER_PLUGIN_IMPL_H__
+++ /dev/null
-# tv profile internal files
-tizen_adaptor_internal_common_src_files += \
- $(tizen_adaptor_internal_src_dir)/../tv/tv-key-impl.cpp \
- $(tizen_adaptor_internal_src_dir)/../tv/tv-render-surface-factory.cpp \
- $(tizen_adaptor_internal_src_dir)/../tv/tv-system-settings.cpp \
- $(tizen_adaptor_internal_src_dir)/../tv/tv-color-controller-impl.cpp
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <internal/common/color-controller-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-Dali::ColorController ColorController::Get()
-{
- Dali::ColorController colorController;
- return colorController;
-}
-
-ColorController::ColorController()
-{
-}
-
-ColorController::~ColorController()
-{
-}
-
-bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
-{
- return false;
-}
-
-bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
-{
- return false;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <internal/common/key-impl.h>
-
-// EXTERNAL INCLUDES
-#include <utilX.h>
-#include <map>
-#include <string.h>
-#include <iostream>
-
-
-#include <dali/integration-api/debug.h>
-
-
-namespace Dali
-{
-
-const KEY DALI_KEY_INVALID = -1;
-const KEY DALI_KEY_ESCAPE = 9;
-const KEY DALI_KEY_BACK = 166;
-const KEY DALI_KEY_CAMERA = 167;
-const KEY DALI_KEY_CONFIG = 168;
-const KEY DALI_KEY_POWER = 169;
-const KEY DALI_KEY_PAUSE = 170;
-const KEY DALI_KEY_CANCEL = 171;
-const KEY DALI_KEY_PLAY_CD = 172;
-const KEY DALI_KEY_STOP_CD = 173;
-const KEY DALI_KEY_PAUSE_CD = 174;
-const KEY DALI_KEY_NEXT_SONG = 175;
-const KEY DALI_KEY_PREVIOUS_SONG = 176;
-const KEY DALI_KEY_REWIND = 177;
-const KEY DALI_KEY_FASTFORWARD = 178;
-const KEY DALI_KEY_MEDIA = 179;
-const KEY DALI_KEY_PLAY_PAUSE = 180;
-const KEY DALI_KEY_MUTE = 181;
-const KEY DALI_KEY_SEND = 182;
-const KEY DALI_KEY_SELECT = 183;
-const KEY DALI_KEY_END = DALI_KEY_BACK;
-const KEY DALI_KEY_MENU = DALI_KEY_SEND;
-const KEY DALI_KEY_HOME = DALI_KEY_SELECT;
-const KEY DALI_KEY_HOMEPAGE = 187;
-const KEY DALI_KEY_WEBPAGE = 188;
-const KEY DALI_KEY_MAIL = 189;
-const KEY DALI_KEY_SCREENSAVER = 190;
-const KEY DALI_KEY_BRIGHTNESS_UP = 191;
-const KEY DALI_KEY_BRIGHTNESS_DOWN = 192;
-const KEY DALI_KEY_SOFT_KBD = 193;
-const KEY DALI_KEY_QUICK_PANEL = 194;
-const KEY DALI_KEY_TASK_SWITCH = 195;
-const KEY DALI_KEY_APPS = 196;
-const KEY DALI_KEY_SEARCH = 197;
-const KEY DALI_KEY_VOICE = 198;
-const KEY DALI_KEY_LANGUAGE = 199;
-const KEY DALI_KEY_VOLUME_UP = 200;
-const KEY DALI_KEY_VOLUME_DOWN = 201;
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace KeyLookup
-{
-
-namespace
-{
-
-struct KeyLookup
-{
- const char* keyName; ///< X string representation
- const int daliKeyCode; ///< Dali Enum Representation
- const bool deviceButton; ///< Whether the key is from a button on the device
-};
-
-// matches a DALI_KEY enum, to a X key name
-KeyLookup KeyLookupTable[]=
-{
- // more than one key name can be assigned to a single dali-key code
- // e.g. Menu and KEY_MENU("FS86KeyMenu") are both assigned to DALI_KEY_MENU
-
- { "Escape", DALI_KEY_ESCAPE, false }, // item not defined in utilX
- { "Menu", DALI_KEY_MENU, false }, // item not defined in utilX
-// { KEY_CAMERA, DALI_KEY_CAMERA, false },
-// { KEY_CONFIG, DALI_KEY_CONFIG, false },
- { KEY_POWER, DALI_KEY_POWER, true },
- { KEY_PAUSE, DALI_KEY_PAUSE, false },
- { KEY_CANCEL, DALI_KEY_CANCEL, false },
-// { KEY_PLAYCD, DALI_KEY_PLAY_CD, false },
-// { KEY_STOPCD, DALI_KEY_STOP_CD, false },
-// { KEY_PAUSECD, DALI_KEY_PAUSE_CD, false },
-// { KEY_NEXTSONG, DALI_KEY_NEXT_SONG, false },
-// { KEY_PREVIOUSSONG, DALI_KEY_PREVIOUS_SONG, false },
-// { KEY_REWIND, DALI_KEY_REWIND, false },
-// { KEY_FASTFORWARD, DALI_KEY_FASTFORWARD, false },
-// { KEY_MEDIA, DALI_KEY_MEDIA, false },
-// { KEY_PLAYPAUSE, DALI_KEY_PLAY_PAUSE, false },
- { KEY_MUTE, DALI_KEY_MUTE, false },
-// { KEY_SEND, DALI_KEY_SEND, true },
-// { KEY_SELECT, DALI_KEY_SELECT, true },
-// { KEY_END, DALI_KEY_END, true },
- { KEY_MENU, DALI_KEY_MENU, true },
- { KEY_HOME, DALI_KEY_HOME, true },
- { KEY_BACK, DALI_KEY_BACK, true },
-// { KEY_HOMEPAGE, DALI_KEY_HOMEPAGE, false },
-// { KEY_WEBPAGE, DALI_KEY_WEBPAGE, false },
-// { KEY_MAIL, DALI_KEY_MAIL, false },
-// { KEY_SCREENSAVER, DALI_KEY_SCREENSAVER, false },
-// { KEY_BRIGHTNESSUP, DALI_KEY_BRIGHTNESS_UP, false },
-// { KEY_BRIGHTNESSDOWN, DALI_KEY_BRIGHTNESS_DOWN, false },
-// { KEY_SOFTKBD, DALI_KEY_SOFT_KBD, false },
-// { KEY_QUICKPANEL, DALI_KEY_QUICK_PANEL, false },
-// { KEY_TASKSWITCH, DALI_KEY_TASK_SWITCH, false },
-// { KEY_APPS, DALI_KEY_APPS, false },
- { KEY_SEARCH, DALI_KEY_SEARCH, false },
-// { KEY_VOICE, DALI_KEY_VOICE, false },
-// { KEY_LANGUAGE, DALI_KEY_LANGUAGE, false },
- { KEY_VOLUMEUP, DALI_KEY_VOLUME_UP, true },
- { KEY_VOLUMEDOWN, DALI_KEY_VOLUME_DOWN, true },
-};
-
-const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable))/ (sizeof(KeyLookup));
-
-class KeyMap
-{
- public:
-
- KeyMap():
- mLookup( cmpString )
- {
- // create the lookup
- for( size_t i = 0; i < KEY_LOOKUP_COUNT ; ++i )
- {
- const KeyLookup& keyLookup( KeyLookupTable[i] );
- mLookup[ keyLookup.keyName ] = DaliKeyType( keyLookup.daliKeyCode, keyLookup.deviceButton );
- }
- }
-
- int GetDaliKeyEnum( const char* keyName ) const
- {
- Lookup::const_iterator i = mLookup.find( keyName );
- if( i == mLookup.end() )
- {
- return -1;
- }
- else
- {
- return (*i).second.first;
- }
- }
-
- bool IsDeviceButton( const char* keyName ) const
- {
- Lookup::const_iterator i = mLookup.find( keyName );
- if ( i != mLookup.end() )
- {
- return (*i).second.second;
- }
- return false;
- }
-
- private:
-
- /**
- * compare function, to compare string by pointer
- */
- static bool cmpString( const char* a, const char* b)
- {
- return strcmp(a, b) < 0;
- }
-
- typedef std::pair< int, bool > DaliKeyType;
- typedef std::map<const char* /* key name */, DaliKeyType /* key code */, bool(*) ( char const* a, char const* b) > Lookup;
- Lookup mLookup;
-
-};
-const KeyMap globalKeyLookup;
-
-} // un-named name space
-
-bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey)
-{
- int key = globalKeyLookup.GetDaliKeyEnum( keyEvent.keyPressedName.c_str() );
- return daliKey == key;
-}
-
-bool IsDeviceButton( const char* keyName )
-{
- return globalKeyLookup.IsDeviceButton( keyName );
-}
-
-} // namespace KeyLookup
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <internal/common/ecore-x/pixmap-render-surface.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-namespace ECoreX
-{
-
-DALI_EXPORT_API RenderSurface* CreatePixmapSurface(
- PositionSize positionSize,
- Any surface,
- Any display,
- const std::string& name,
- bool isTransparent )
-{
- return new PixmapRenderSurface( positionSize, surface, display, name, isTransparent );
-}
-
-} // namespace ECoreX
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-
-
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <system_settings.h>
-#include <Elementary.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/system-settings.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-int GetLongPressTime( int defaultTime )
-{
- return defaultTime;
-}
-
-int GetElmAccessActionOver()
-{
- return ELM_ACCESS_ACTION_OVER;
-}
-
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-# Public source files
-tizen_application_public_api_src_files = \
- $(tizen_application_public_api_src_dir)/adaptor-framework/application.cpp
-
-# Exported header files
-tizen_application_public_api_header_files = \
- $(tizen_application_public_api_src_dir)/adaptor-framework/application.h
-
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "application.h"
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/common/orientation.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <internal/application-impl.h>
-#include <internal/common/orientation-impl.h>
-
-namespace Dali
-{
-
-Application Application::New( int* argc, char **argv[] )
-{
- Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, "Dali Application", DeviceLayout::DEFAULT_BASE_LAYOUT, OPAQUE );
- return Application(internal.Get());
-}
-
-Application Application::New( int* argc, char **argv[], const std::string& name )
-{
- Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, name, DeviceLayout::DEFAULT_BASE_LAYOUT, OPAQUE );
- return Application(internal.Get());
-}
-
-Application Application::New( int* argc, char **argv[], const std::string& name, WINDOW_MODE windowMode )
-{
- Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, name, DeviceLayout::DEFAULT_BASE_LAYOUT, windowMode );
- return Application(internal.Get());
-}
-
-Application Application::New(int* argc, char **argv[], const DeviceLayout& baseLayout)
-{
- Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, "Dali Application", baseLayout, OPAQUE );
- return Application(internal.Get());
-}
-
-Application Application::New(int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout)
-{
- Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, name, baseLayout, OPAQUE );
- return Application(internal.Get());
-}
-
-Application::~Application()
-{
-}
-
-Application::Application(const Application& application)
-: BaseHandle(application)
-{
-}
-
-Application& Application::operator=(const Application& application)
-{
- if( *this != application )
- {
- BaseHandle::operator=( application );
- }
- return *this;
-}
-
-void Application::MainLoop()
-{
- Internal::Adaptor::GetImplementation(*this).MainLoop();
-}
-
-void Application::Lower()
-{
- Internal::Adaptor::GetImplementation(*this).Lower();
-}
-
-void Application::Quit()
-{
- Internal::Adaptor::GetImplementation(*this).Quit();
-}
-
-Orientation Application::GetOrientation()
-{
- Window window = GetWindow();
- if( window )
- {
- return window.GetOrientation();
- }
- return Orientation();
-}
-
-bool Application::AddIdle(boost::function<void(void)> callBack)
-{
- return Internal::Adaptor::GetImplementation(*this).AddIdle(callBack);
-}
-
-Window Application::GetWindow()
-{
- return Internal::Adaptor::GetImplementation(*this).GetWindow();
-}
-
-Application Application::Get()
-{
- return Internal::Adaptor::Application::Get();
-}
-
-void Application::SetViewMode( ViewMode viewMode )
-{
- Internal::Adaptor::GetImplementation(*this).SetViewMode( viewMode );
-}
-
-ViewMode Application::GetViewMode() const
-{
- return Internal::Adaptor::GetImplementation(*this).GetViewMode();
-}
-
-void Application::SetStereoBase( float stereoBase )
-{
- Internal::Adaptor::GetImplementation(*this).SetStereoBase( stereoBase );
-}
-
-float Application::GetStereoBase() const
-{
- return Internal::Adaptor::GetImplementation(*this).GetStereoBase();
-}
-
-Application::AppSignalV2& Application::InitSignal()
-{
- return Internal::Adaptor::GetImplementation(*this).InitSignal();
-}
-
-Application::AppSignalV2& Application::TerminateSignal()
-{
- return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
-}
-
-Application::AppSignalV2& Application::PauseSignal()
-{
- return Internal::Adaptor::GetImplementation(*this).PauseSignal();
-}
-
-Application::AppSignalV2& Application::ResumeSignal()
-{
- return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
-}
-
-Application::AppSignalV2& Application::ResetSignal()
-{
- return Internal::Adaptor::GetImplementation(*this).ResetSignal();
-}
-
-Application::AppSignalV2& Application::ResizeSignal()
-{
- return Internal::Adaptor::GetImplementation(*this).ResizeSignal();
-}
-
-Application::AppSignalV2& Application::LanguageChangedSignal()
-{
- return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
-}
-
-Application::Application(Internal::Adaptor::Application* application)
-: BaseHandle(application)
-{
-}
-
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_APPLICATION_H__
-#define __DALI_APPLICATION_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-#include <string>
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/common/view-mode.h>
-
-#include <dali/public-api/adaptor-framework/common/style-monitor.h>
-#include <dali/public-api/adaptor-framework/common/device-layout.h>
-#include <dali/public-api/adaptor-framework/common/window.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class Application;
-}
-}
-
-/**
- * An Application class object should be created by every application
- * that wishes to use Dali. It provides a means for initialising the
- * resources required by the Dali::Core.
- *
- * The Application class emits several signals which the user can
- * connect to. The user should not create any Dali objects in the main
- * function and instead should connect to the Init signal of the
- * Application and create the Dali objects in the connected callback.
- *
- * Applications should follow the example below:
- *
- * @code
- * void CreateProgram(Application app)
- * {
- * // Create Dali components...
- * // Can instantiate here, if required
- * }
- *
- * int main (int argc, char **argv)
- * {
- * Application app = Application::New(&argc, &argv);
- * app.InitSignal().Connect(&CreateProgram);
- * app.MainLoop();
- * }
- * @endcode
- *
- * If required, you can also connect class member functions to a signal:
- *
- * @code
- * MyApplication app;
- * app.ResumeSignal().Connect(&app, &MyApplication::Resume);
- * @endcode
- *
- * This class accepts command line arguments as well. The following options are supported:
- *
- * @code
- * --no-vsync Disable VSync on Render
- * -w|--width Stage Width
- * -h|--height Stage Height
- * -d|--dpi Emulated DPI
- * --help Help
- * @endcode
- *
- * When the above options are found, they are stripped from argv, and argc is updated appropriately.
- */
-class Application : public BaseHandle
-{
-public:
-
- typedef SignalV2< void (Application&) > AppSignalV2;
-
- /**
- * Decides whether a Dali application window is opaque or transparent.
- */
- enum WINDOW_MODE
- {
- OPAQUE = 0, ///< The window will be opaque
- TRANSPARENT = 1 ///< The window transparency will match the alpha value set in Dali::Stage::SetBackgroundcolor()
- };
-
-public:
-
- /**
- * This is the constructor for applications.
- *
- * @param[in,out] argc A pointer to the number of arguments
- * @param[in,out] argv A pointer the the argument list
- *
- * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
- * @note Supported options are stripped from argv, and argc is updated appropriately.
- */
- static Application New( int* argc, char **argv[] );
-
- /**
- * This is the constructor for applications with a name
- *
- * @param[in,out] argc A pointer to the number of arguments
- * @param[in,out] argv A pointer the the argument list
- * @param[in] name A name of application
- *
- * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
- * @note Supported options are stripped from argv, and argc is updated appropriately.
- */
- static Application New( int* argc, char **argv[], const std::string& name );
-
- /**
- * This is the constructor for applications with a name, and also require a
- * transparent top-level window
- *
- * @param[in,out] argc A pointer to the number of arguments
- * @param[in,out] argv A pointer the the argument list
- * @param[in] name A name of application
- * @param[in] windowMode A member of WINDOW_MODE
- *
- * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
- * @note Supported options are stripped from argv, and argc is updated appropriately.
- */
- static Application New( int* argc, char **argv[], const std::string& name, WINDOW_MODE windowMode );
-
- /**
- * This is the constructor for applications when a layout for the application is specified.
- *
- * @param[in,out] argc A pointer to the number of arguments
- * @param[in,out] argv A pointer the the argument list
- * @param[in] baseLayout The base layout that the application has been written for
- *
- * @note Supported options are stripped from argv, and argc is updated appropriately.
- */
- static Application New( int* argc, char **argv[], const DeviceLayout& baseLayout );
-
- /**
- * This is the constructor for applications with a name and when a layout for the application is specified.
- *
- * @param[in,out] argc A pointer to the number of arguments
- * @param[in,out] argv A pointer the the argument list
- * @param[in] name A name of application
- * @param[in] baseLayout The base layout that the application has been written for
- *
- * @note Supported options are stripped from argv, and argc is updated appropriately.
- */
- static Application New( int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout );
-
- /**
- * Construct an empty handle
- */
- Application();
-
- /**
- * Copy Constructor
- */
- Application( const Application& application );
-
- /**
- * Assignment operator
- */
- Application& operator=( const Application& applicaton );
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~Application();
-
-public:
- /**
- * This starts the application.
- */
- void MainLoop();
-
- /**
- * This lowers the application to bottom without actually quitting it
- */
- void Lower();
-
- /**
- * This quits the application. Tizen applications should use Lower to improve re-start performance unless they need to Quit completely.
- */
- void Quit();
-
- /**
- * This returns a handle to the Orientation object used by Application which allows
- * the user to determine the orientation of the device and connect to a
- * signal emitted whenever the orientation changes.
- * @return A handle to the Orientation object used by the Application
- */
- Orientation GetOrientation();
-
- /**
- * Ensures that the function passed in is called from the main loop when it is idle.
- *
- * A callback of the following type may be used:
- * @code
- * void MyFunction();
- * @endcode
- *
- * @param[in] callBack The function to call.
- * @return true if added successfully, false otherwise
- */
- bool AddIdle(boost::function<void(void)> callBack);
-
- /**
- * Retrieves the window used by the Application class.
- * The application writer can use the window to change indicator and orientation
- * properties.
- * @return A handle to the window
- */
- Window GetWindow();
-
- /**
- * Returns the local thread's instance of the Application class.
- * @return A reference to the local thread's Application class instance.
- * @pre The Application class has been initialised.
- * @note This is only valid in the main thread.
- */
- static Application Get();
-
-public: // Stereoscopy
-
- /**
- * Set the stereoscopic 3D viewing mode for the application
- * @param[in] viewMode The new viewing mode
- */
- void SetViewMode( ViewMode viewMode );
-
- /**
- * Get the current stereoscopic 3D viewing mode.
- * @return The current stereoscopic 3D viewing mode.
- */
- ViewMode GetViewMode() const;
-
- /**
- * Set the stereo base (eye seperation) for stereoscopic 3D
- * @param[in] stereoBase The stereo base (eye seperation) for stereoscopic 3D
- */
- void SetStereoBase( float stereoBase );
-
- /**
- * Get the stereo base (eye seperation) for stereoscopic 3D
- * @return The stereo base (eye seperation) for stereoscopic 3D
- */
- float GetStereoBase() const;
-
-public: // Signals
-
- /**
- * The user should connect to this signal to determine when they should initialise
- * their application
- */
- AppSignalV2& InitSignal();
-
- /**
- * The user should connect to this signal to determine when they should terminate
- * their application
- */
- AppSignalV2& TerminateSignal();
-
- /**
- * The user should connect to this signal if they need to perform any special
- * activities when the application is about to be paused.
- */
- AppSignalV2& PauseSignal();
-
- /**
- * The user should connect to this signal if they need to perform any special
- * activities when the application has resumed.
- */
- AppSignalV2& ResumeSignal();
-
- /**
- * This signal is sent when the system requires the user to reinitialise itself.
- */
- AppSignalV2& ResetSignal();
-
- /**
- * This signal is emitted when the window the application is rendering on is resized.
- */
- AppSignalV2& ResizeSignal();
-
- /**
- * This signal is emitted when the language is changed on the device.
- */
- AppSignalV2& LanguageChangedSignal();
-
-public: // Not intended for application developers
- /**
- * Internal constructor
- */
- explicit DALI_INTERNAL Application(Internal::Adaptor::Application* application);
-};
-
-} // namespace Dali
-
-#endif // __DALI_APPLICATION_H__
+++ /dev/null
-#ifndef __DALI_ACCESSIBILITY_ACTION_HANDLER_H__
-#define __DALI_ACCESSIBILITY_ACTION_HANDLER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-
-namespace Dali DALI_IMPORT_API
-{
-
-/**
- * AccessibilityActionHandler is an abstract interface, used by Dali to handle accessibility actions
- * passed by the accessibility manager.
- */
-class AccessibilityActionHandler
-{
-public:
-
- /**
- * Change the accessibility status when Accessibility feature(screen-reader) turned on or off.
- * @return whether the status is changed or not.
- */
- virtual bool ChangeAccessibilityStatus() = 0;
-
- /**
- * Clear the accessibility focus from the current focused actor.
- * @return whether the focus is cleared or not.
- */
- virtual bool ClearAccessibilityFocus() = 0;
-
- /**
- * Perform the accessibility action to move focus to the previous focusable actor (by one finger flick up).
- * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionPrevious(bool allowEndFeedback) = 0;
-
- /**
- * Perform the accessibility action to move focus to the next focusable actor (by one finger flick down).
- * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionNext(bool allowEndFeedback) = 0;
-
- /**
- * Perform the accessibility action to move focus to the previous focusable actor (by one finger flick left).
- * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionReadPrevious(bool allowEndFeedback) = 0;
-
- /**
- * Perform the accessibility action to move focus to the next focusable actor (by one finger flick right).
- * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionReadNext(bool allowEndFeedback) = 0;
-
- /**
- * Perform the accessibility action to focus and read the actor (by one finger tap or move).
- * @param allowReadAgain true if the action read again the same object (i.e. read action)
- * false if the action just read when the focus object is changed (i.e. over action)
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionRead(bool allowReadAgain) = 0;
-
- /**
- * Perform the accessibility action to activate the current focused actor (by one finger double tap).
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionActivate() = 0;
-
- /**
- * Perform the accessibility action to change the value when the current focused actor is a slider
- * (by double finger down and move up and right).
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionUp() = 0;
-
- /**
- * Perform the accessibility action to change the value when the current focused actor is a slider
- * (by double finger down and move down and left).
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionDown() = 0;
-
- /**
- * Perform the accessibility action to navigate back (by two fingers circle draw).
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionBack() = 0;
-
- /**
- * Perform the accessibility action to mouse move (by one finger tap & hold and move).
- * @param touchEvent touch event structure
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionTouch(const Dali::TouchEvent& touchEvent) = 0;
-
-}; // class AccessibilityActionHandler
-
-} // namespace Dali
-
-#endif // __DALI_ACCESSIBILITY_ACTION_HANDLER_H__
+++ /dev/null
-#ifndef __DALI_ACCESSIBILITY_GESTURE_HANDLER_H__
-#define __DALI_ACCESSIBILITY_GESTURE_HANDLER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/integration-api/events/pan-gesture-event.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-/**
- * AccessibilityGestureHandler is an interface used by Dali to handle accessibility gestures
- * passed by the accessibility manager.
- */
-class AccessibilityGestureHandler
-{
-public:
-
- /**
- * Handle the accessibility pan gesture.
- * @param[in] panEvent The pan event to be handled.
- * @return whether the gesture is handled successfully or not.
- */
- virtual bool HandlePanGesture( const Integration::PanGestureEvent& panEvent ) = 0;
-
-}; // class AccessibilityGestureHandler
-
-} // namespace Dali
-
-#endif // __DALI_ACCESSIBILITY_GESTURE_HANDLER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/accessibility-manager.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/accessibility-manager-impl.h>
-
-namespace Dali
-{
-
-const char* const AccessibilityManager::SIGNAL_STATUS_CHANGED( "accessibility-status-changed" );
-const char* const AccessibilityManager::SIGNAL_ACTION_NEXT( "accessibility-action-next" );
-const char* const AccessibilityManager::SIGNAL_ACTION_PREVIOUS( "accessibility-action-previous" );
-const char* const AccessibilityManager::SIGNAL_ACTION_ACTIVATE( "accessibility-action-activate" );
-const char* const AccessibilityManager::SIGNAL_ACTION_OVER( "accessibility-action-over" );
-const char* const AccessibilityManager::SIGNAL_ACTION_READ( "accessibility-action-read" );
-const char* const AccessibilityManager::SIGNAL_ACTION_READ_NEXT( "accessibility-action-read-next" );
-const char* const AccessibilityManager::SIGNAL_ACTION_READ_PREVIOUS( "accessibility-action-read-previous" );
-const char* const AccessibilityManager::SIGNAL_ACTION_UP( "accessibility-action-up" );
-const char* const AccessibilityManager::SIGNAL_ACTION_DOWN( "accessibility-action-down" );
-const char* const AccessibilityManager::SIGNAL_ACTION_CLEAR_FOCUS( "accessibility-action-clear-focus" );
-const char* const AccessibilityManager::SIGNAL_ACTION_BACK( "accessibility-action-back" );
-const char* const AccessibilityManager::SIGNAL_ACTION_SCROLL( "accessibility-action-scroll" );
-
-AccessibilityManager::AccessibilityManager()
-{
-}
-
-AccessibilityManager AccessibilityManager::Get()
-{
- return Internal::Adaptor::AccessibilityManager::Get();
-}
-
-AccessibilityManager::~AccessibilityManager()
-{
-}
-
-Vector2 AccessibilityManager::GetReadPosition() const
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).GetReadPosition();
-}
-
-bool AccessibilityManager::IsEnabled() const
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).IsEnabled();
-}
-
-void AccessibilityManager::SetActionHandler(AccessibilityActionHandler& handler)
-{
- Internal::Adaptor::AccessibilityManager::GetImplementation(*this).SetActionHandler(handler);
-}
-
-void AccessibilityManager::SetGestureHandler(AccessibilityGestureHandler& handler)
-{
- Internal::Adaptor::AccessibilityManager::GetImplementation(*this).SetGestureHandler(handler);
-}
-
-bool AccessibilityManager::HandleActionNextEvent(bool allowEndFeedback)
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionNextEvent(allowEndFeedback);
-}
-
-bool AccessibilityManager::HandleActionPreviousEvent(bool allowEndFeedback)
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionPreviousEvent(allowEndFeedback);
-}
-
-bool AccessibilityManager::HandleActionActivateEvent()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionActivateEvent();
-}
-
-bool AccessibilityManager::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionReadEvent(x, y, allowReadAgain);
-}
-
-bool AccessibilityManager::HandleActionReadNextEvent(bool allowEndFeedback)
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionReadNextEvent(allowEndFeedback);
-}
-
-bool AccessibilityManager::HandleActionReadPreviousEvent(bool allowEndFeedback)
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionReadPreviousEvent(allowEndFeedback);
-}
-
-bool AccessibilityManager::HandleActionUpEvent()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionUpEvent();
-}
-
-bool AccessibilityManager::HandleActionDownEvent()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionDownEvent();
-}
-
-bool AccessibilityManager::HandleActionClearFocusEvent()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionClearFocusEvent();
-}
-
-bool AccessibilityManager::HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp)
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionScrollEvent(point, timeStamp);
-}
-
-bool AccessibilityManager::HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp)
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionTouchEvent(point, timeStamp);
-}
-
-bool AccessibilityManager::HandleActionBackEvent()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionBackEvent();
-}
-
-void AccessibilityManager::HandleActionEnableEvent()
-{
- Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionEnableEvent();
-}
-
-void AccessibilityManager::HandleActionDisableEvent()
-{
- Internal::Adaptor::AccessibilityManager::GetImplementation(*this).HandleActionDisableEvent();
-}
-
-AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::StatusChangedSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).StatusChangedSignal();
-}
-
-AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionNextSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionNextSignal();
-}
-
-AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionPreviousSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionPreviousSignal();
-}
-
-AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionActivateSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionActivateSignal();
-}
-
-AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionOverSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionOverSignal();
-}
-
-AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionReadSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionReadSignal();
-}
-
-AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionReadNextSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionReadNextSignal();
-}
-
-AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionReadPreviousSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionReadPreviousSignal();
-}
-
-AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionUpSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionUpSignal();
-}
-
-AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionDownSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionDownSignal();
-}
-
-AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionClearFocusSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionClearFocusSignal();
-}
-
-AccessibilityManager::AccessibilityActionSignalV2& AccessibilityManager::ActionBackSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionBackSignal();
-}
-
-AccessibilityManager::AccessibilityActionScrollSignalV2& AccessibilityManager::ActionScrollSignal()
-{
- return Internal::Adaptor::AccessibilityManager::GetImplementation(*this).ActionScrollSignal();
-}
-
-AccessibilityManager::AccessibilityManager( Internal::Adaptor::AccessibilityManager& manager )
-: BaseHandle( &manager )
-{
-}
-
-AccessibilityManager::AccessibilityManager( Internal::Adaptor::AccessibilityManager* manager )
-: BaseHandle( manager )
-{
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/adaptor.h>
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/adaptor-framework/common/accessibility-manager.h>
-#include <dali/public-api/adaptor-framework/common/imf-manager.h>
-#include <dali/public-api/adaptor-framework/common/style-monitor.h>
-#include <dali/public-api/adaptor-framework/common/window.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/adaptor-impl.h>
-#include <internal/common/render-surface-impl.h>
-#include <internal/common/window-impl.h>
-
-namespace Dali
-{
-
-Adaptor& Adaptor::New( Window window )
-{
- return New( window, DeviceLayout::DEFAULT_BASE_LAYOUT );
-}
-
-Adaptor& Adaptor::New( Window window, const DeviceLayout& baseLayout )
-{
- Internal::Adaptor::Window& windowImpl = GetImplementation(window);
- Adaptor* adaptor = Internal::Adaptor::Adaptor::New( windowImpl.GetSurface(), baseLayout );
- windowImpl.SetAdaptor(*adaptor);
- return *adaptor;
-}
-
-Adaptor::~Adaptor()
-{
- delete mImpl;
-}
-
-void Adaptor::Start()
-{
- mImpl->Start();
-}
-
-void Adaptor::Pause()
-{
- mImpl->Pause();
-}
-
-void Adaptor::Resume()
-{
- mImpl->Resume();
-}
-
-void Adaptor::Stop()
-{
- mImpl->Stop();
-}
-
-bool Adaptor::AddIdle( boost::function<void(void)> callBack )
-{
- return mImpl->AddIdle(callBack);
-}
-
-Adaptor::AdaptorSignalV2& Adaptor::ResizedSignal()
-{
- return mImpl->ResizedSignal();
-}
-
-Adaptor::AdaptorSignalV2& Adaptor::LanguageChangedSignal()
-{
- return mImpl->LanguageChangedSignal();
-}
-
-RenderSurface& Adaptor::GetSurface()
-{
- return mImpl->GetSurface();
-}
-
-Adaptor& Adaptor::Get()
-{
- return Internal::Adaptor::Adaptor::Get();
-}
-
-bool Adaptor::IsAvailable()
-{
- return Internal::Adaptor::Adaptor::IsAvailable();
-}
-
-void Adaptor::RegisterSingleton(const std::type_info& info, BaseHandle singleton)
-{
- mImpl->RegisterSingleton(info, singleton);
-}
-
-BaseHandle Adaptor::GetSingleton(const std::type_info& info) const
-{
- return mImpl->GetSingleton(info);
-}
-
-void Adaptor::NotifyLanguageChanged()
-{
- mImpl->NotifyLanguageChanged();
-}
-
-void Adaptor::SetMinimumPinchDistance(float distance)
-{
- mImpl->SetMinimumPinchDistance(distance);
-}
-
-Adaptor::Adaptor()
-: mImpl( NULL )
-{
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/clipboard-event-notifier.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/clipboard-event-notifier-impl.h>
-
-namespace Dali
-{
-
-const char* const ClipboardEventNotifier::SIGNAL_CONTENT_SELECTED( "content-selected" );
-
-ClipboardEventNotifier::ClipboardEventNotifier()
-{
-}
-
-ClipboardEventNotifier ClipboardEventNotifier::Get()
-{
- return Internal::Adaptor::ClipboardEventNotifier::Get();
-}
-
-ClipboardEventNotifier::~ClipboardEventNotifier()
-{
-}
-
-const std::string& ClipboardEventNotifier::GetContent() const
-{
- return Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).GetContent();
-}
-
-void ClipboardEventNotifier::SetContent( const std::string& content )
-{
- Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).SetContent(content);
-}
-
-void ClipboardEventNotifier::ClearContent()
-{
- Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).ClearContent();
-}
-
-void ClipboardEventNotifier::EmitContentSelectedSignal()
-{
- Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).EmitContentSelectedSignal();
-}
-
-ClipboardEventNotifier::ClipboardEventSignalV2& ClipboardEventNotifier::ContentSelectedSignal()
-{
- return Internal::Adaptor::ClipboardEventNotifier::GetImplementation(*this).ContentSelectedSignal();
-}
-
-ClipboardEventNotifier::ClipboardEventNotifier( Internal::Adaptor::ClipboardEventNotifier* notifier )
-: BaseHandle( notifier )
-{
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/clipboard.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/clipboard-impl.h>
-
-namespace Dali
-{
-
-Clipboard::Clipboard()
-{
-}
-Clipboard::~Clipboard()
-{
-}
-Clipboard::Clipboard(Internal::Adaptor::Clipboard *impl)
- : BaseHandle(impl)
-{
-}
-
-Clipboard Clipboard::Get()
-{
- return Internal::Adaptor::Clipboard::Get();
-}
-bool Clipboard::SetItem( const std::string &itemData)
-{
- return GetImplementation(*this).SetItem( itemData );
-}
-
-std::string Clipboard::GetItem( unsigned int index )
-{
- return GetImplementation(*this).GetItem( index );
-}
-
-unsigned int Clipboard::NumberOfItems()
-{
- return GetImplementation(*this).NumberOfItems();
-}
-
-void Clipboard::ShowClipboard()
-{
- GetImplementation(*this).ShowClipboard();
-}
-
-void Clipboard::HideClipboard()
-{
- GetImplementation(*this).HideClipboard();
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <public-api/adaptor-framework/common/color-controller.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/color-controller-impl.h>
-
-namespace Dali
-{
-
-ColorController::ColorController()
-{
-}
-
-ColorController::ColorController(const ColorController& controller)
-: BaseHandle(controller)
-{
-}
-
-ColorController ColorController::Get()
-{
- return Internal::Adaptor::ColorController::Get();
-}
-
-ColorController::~ColorController()
-{
-}
-
-bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
-{
- return GetImplementation(*this).RetrieveColor( colorCode, colorValue );
-}
-
-bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
-{
- return GetImplementation(*this).RetrieveColor( colorCode, textColor, textOutlineColor, textShadowColor );
-}
-
-ColorController::ColorController(Internal::Adaptor::ColorController* internal)
-: BaseHandle(internal)
-{
-}
-
-}
+++ /dev/null
-#ifndef __DALI_COLOR_CONTROLLER_H__
-#define __DALI_COLOR_CONTROLLER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/public-api/object/base-handle.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class ColorController;
-}
-}
-
-/**
- * Color controller currently caches the changeable color table which updates with the theme change
- *
- * It provides the functionality of retrieving a RGBA color by passing in the color code string.
- */
-class ColorController : public BaseHandle
-{
-public:
-
- /**
- * @brief Create an uninitialized ColorController handle.
- */
- ColorController();
-
- /**
- * @brief Creates a copy of the handle.
- *
- * The copy will point to the same implementation as the original.
- * @param[in] colorController The Color Controller to copy from.
- */
- ColorController( const ColorController& colorController);
-
- /**
- * @copydoc Dali::BaseHandle::operator=
- */
- using BaseHandle::operator=;
-
- /**
- * @brief Retrieve the initialized instance of the ColorController.
- *
- * @return Handle to ColorController.
- */
- static ColorController Get();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~ColorController();
-
- /**
- * @brief Retrieve the RGB value by given the color code.
- *
- * @param[in] colorCode The color code string.
- * @param[out] colorValue The RGBA color
- * @return true if the color code exists, otherwise false
- */
- bool RetrieveColor( const std::string& colorCode, Vector4& colorValue );
-
- /**
- * @brief Retrieve the RGB values by given the color code.
- *
- * @param[in] colorCode The color code string.
- * @param[out] textColor The text color.
- * @param[out] textOutlineColor The text outline color.
- * @param[out] textShadowColor The text shadow color.
- * @return true if the color code exists, otherwise false
- */
- bool RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor);
-
-
-public: // Not intended for application developers
- /**
- * @brief This constructor is used internally to create a handle from an object pointer.
- * @param [in] colorController A pointer the internal color controller.
- */
- explicit DALI_INTERNAL ColorController(Internal::Adaptor::ColorController* colorController);
-};
-
-
-} //namespace Dali
-
-#endif /* __DALI_COLOR_CONTROLLER_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/device-layout.h>
-
-namespace Dali
-{
-
-const DeviceLayout DeviceLayout::DEFAULT_BASE_LAYOUT
-(
- Vector2(720.0f, 1280.0f), // The resolution of the screen
- 4.65f, // The screen size
- Vector2(316.0f, 316.0f), // The DPI
- 30.0f // The Viewing Distance
-);
-
-DeviceLayout::DeviceLayout()
-: resolution(),
- screenSize(0.0f),
- dpi(),
- viewingDistance(0.0f)
-{
-}
-
-DeviceLayout::DeviceLayout(Vector2 resolution, float screenSize, Vector2 dpi, float viewingDistance)
-: resolution(resolution),
- screenSize(screenSize),
- dpi(dpi),
- viewingDistance(viewingDistance)
-{
-}
-
-DeviceLayout::~DeviceLayout()
-{
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/drag-and-drop-detector.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/drag-and-drop-detector-impl.h>
-
-namespace Dali
-{
-
-const char* const DragAndDropDetector::SIGNAL_ENTERED( "drag-and-drop-entered" );
-const char* const DragAndDropDetector::SIGNAL_EXITED( "drag-and-drop-exited" );
-const char* const DragAndDropDetector::SIGNAL_MOVED( "drag-and-drop-moved" );
-const char* const DragAndDropDetector::SIGNAL_DROPPED( "drag-and-drop-dropped" );
-
-DragAndDropDetector::DragAndDropDetector()
-{
-}
-
-DragAndDropDetector::~DragAndDropDetector()
-{
-}
-
-const std::string& DragAndDropDetector::GetContent() const
-{
- return GetImplementation(*this).GetContent();
-}
-
-Vector2 DragAndDropDetector::GetCurrentScreenPosition() const
-{
- return GetImplementation(*this).GetCurrentScreenPosition();
-}
-
-DragAndDropDetector::DragAndDropSignalV2& DragAndDropDetector::EnteredSignal()
-{
- return GetImplementation(*this).EnteredSignal();
-}
-
-DragAndDropDetector::DragAndDropSignalV2& DragAndDropDetector::ExitedSignal()
-{
- return GetImplementation(*this).ExitedSignal();
-}
-
-DragAndDropDetector::DragAndDropSignalV2& DragAndDropDetector::MovedSignal()
-{
- return GetImplementation(*this).MovedSignal();
-}
-
-DragAndDropDetector::DragAndDropSignalV2& DragAndDropDetector::DroppedSignal()
-{
- return GetImplementation(*this).DroppedSignal();
-}
-
-DragAndDropDetector::DragAndDropDetector( Internal::Adaptor::DragAndDropDetector* detector )
-: BaseHandle( detector )
-{
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// HEADER
-#include <public-api/adaptor-framework/common/event-feeder.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-
-namespace EventFeeder
-{
-
-void FeedTouchPoint( TouchPoint& point, int timeStamp )
-{
- if ( Adaptor::IsAvailable() )
- {
- Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).FeedTouchPoint( point, timeStamp );
- }
-}
-
-void FeedWheelEvent( MouseWheelEvent& wheelEvent )
-{
- if ( Adaptor::IsAvailable() )
- {
- Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).FeedWheelEvent( wheelEvent );
- }
-}
-
-void FeedKeyEvent( KeyEvent& keyEvent )
-{
- if ( Adaptor::IsAvailable() )
- {
- Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).FeedKeyEvent( keyEvent );
- }
-}
-
-} // namespace EventFeeder
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_EVENT_FEEDER_H_
-#define __DALI_EVENT_FEEDER_H_
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-struct KeyEvent;
-struct MouseWheelEvent;
-struct TouchPoint;
-
-namespace EventFeeder
-{
-
-/**
- * Feed a touch point to the adaptor.
- *
- * @param[in] point touch point
- * @param[in] timeStamp time value of event
- *
- * @note For testing/automation purposes only.
- */
-void FeedTouchPoint( TouchPoint& point, int timeStamp );
-
-/**
- * Feed a mouse wheel event to the adaptor.
- *
- * @param[in] wheelEvent mouse wheel event
- *
- * @note For testing/automation purposes only.
- */
-void FeedWheelEvent( MouseWheelEvent& wheelEvent );
-
-/**
- * Feed a key event to the adaptor.
- *
- * @param[in] keyEvent The key event holding the key information.
- *
- * @note For testing/automation purposes only.
- */
-void FeedKeyEvent( KeyEvent& keyEvent );
-
-} // namespace EventFeeder
-
-} // namespace Dali
-
-#endif // __DALI_EVENT_FEEDER_H_
+++ /dev/null
-#ifndef __DALI_FEEDBACK_PLUGIN_H__
-#define __DALI_FEEDBACK_PLUGIN_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-/**
- * FeedbackPlugin is an abstract interface, used by Dali-adaptor to access haptic and audio feedback.
- * A concrete implementation must be created for each platform and provided as a dynamic library which
- * will be loaded at run time by the adaptor.
- */
-class FeedbackPlugin
-{
-public:
-
- typedef void (*SoundStopCallBack)( void* ptr );
-
- /**
- * Destructor.
- */
- virtual ~FeedbackPlugin()
- {
- }
-
- /**
- * Plays vibration in predefined patterns.
- * @param[in] filePath Path to the file containing the effect.
- */
- virtual void PlayHaptic( const std::string& filePath ) = 0;
-
- /**
- * Plays a monotone vibration.
- * @param[in] duration The duration of the vibration.
- */
- virtual void PlayHapticMonotone( unsigned int duration ) = 0;
-
- /**
- * Stops the currently playing vibration effects.
- */
- virtual void StopHaptic() = 0;
-
- /**
- * Plays a sound file.
- * @param[in] fileName Path to the sound file to play.
- * @return A handle which can be used to stop the sound playback.
- */
- virtual int PlaySound( const std::string& fileName ) = 0;
-
- /**
- * Stops a currently playing sound.
- * @param[in] handle A handle to the currently playing sound.
- */
- virtual void StopSound( int handle ) = 0;
-
- /**
- * Plays a feedback pattern.
- * @param[in] type The type of feedback.
- * @param[in] pattern The ID of the pattern to play.
- */
- virtual void PlayFeedbackPattern( int type, int pattern ) = 0;
-
- // Types for plugin factories
-
- /**
- * Function pointer called in adaptor to create a feedback plugin instance.
- * @param [in] pluginName name of the plugin to load.
- * @return Pointer to the newly created plugin object
- */
- typedef FeedbackPlugin* CreateFeedbackPlugin( void );
-
-}; // class FeedbackPlugin
-
-} // namespace Dali
-
-#endif // __DALI_FEEDBACK_PLUGIN_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/haptic-player.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/haptic-player-impl.h>
-
-namespace Dali
-{
-
-HapticPlayer::HapticPlayer()
-{
-}
-
-HapticPlayer HapticPlayer::Get()
-{
- return Internal::Adaptor::HapticPlayer::Get();
-}
-
-HapticPlayer::~HapticPlayer()
-{
-}
-
-void HapticPlayer::PlayMonotone(unsigned int duration)
-{
- GetImplementation(*this).PlayMonotone(duration);
-}
-
-void HapticPlayer::PlayFile(const std::string filePath)
-{
- GetImplementation(*this).PlayFile(filePath);
-}
-
-void HapticPlayer::Stop()
-{
- GetImplementation(*this).Stop();
-}
-
-HapticPlayer::HapticPlayer( Internal::Adaptor::HapticPlayer* player )
-: BaseHandle( player )
-{
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/imf-manager.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/imf-manager-impl.h>
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-
-ImfManager::ImfManager()
-{
-}
-
-ImfManager::~ImfManager()
-{
-}
-
-ImfManager ImfManager::Get()
-{
- return Internal::Adaptor::ImfManager::Get();
-}
-
-ImfContext ImfManager::GetContext()
-{
- return reinterpret_cast<ImfContext>( Internal::Adaptor::ImfManager::GetImplementation(*this).GetContext() );
-}
-
-void ImfManager::Activate()
-{
- Internal::Adaptor::ImfManager::GetImplementation(*this).Activate();
-}
-
-void ImfManager::Deactivate()
-{
- Internal::Adaptor::ImfManager::GetImplementation(*this).Deactivate();
-}
-
-bool ImfManager::RestoreAfterFocusLost() const
-{
- return Internal::Adaptor::ImfManager::GetImplementation(*this).RestoreAfterFocusLost();
-}
-
-void ImfManager::SetRestoreAferFocusLost( bool toggle )
-{
- Internal::Adaptor::ImfManager::GetImplementation(*this).SetRestoreAferFocusLost( toggle );
-}
-
-void ImfManager::Reset()
-{
- Internal::Adaptor::ImfManager::GetImplementation(*this).Reset();
-}
-
-void ImfManager::NotifyCursorPosition()
-{
- Internal::Adaptor::ImfManager::GetImplementation(*this).NotifyCursorPosition();
-}
-
-void ImfManager::SetCursorPosition( unsigned int SetCursorPosition )
-{
- Internal::Adaptor::ImfManager::GetImplementation(*this).SetCursorPosition( SetCursorPosition );
-}
-
-int ImfManager::GetCursorPosition()
-{
- return Internal::Adaptor::ImfManager::GetImplementation(*this).GetCursorPosition();
-}
-
-void ImfManager::SetSurroundingText( std::string text )
-{
- Internal::Adaptor::ImfManager::GetImplementation(*this).SetSurroundingText( text );
-}
-
-std::string ImfManager::GetSurroundingText()
-{
- return Internal::Adaptor::ImfManager::GetImplementation(*this).GetSurroundingText();
-}
-
-ImfManager::ImfManagerSignalV2& ImfManager::ActivatedSignal()
-{
- return Internal::Adaptor::ImfManager::GetImplementation(*this).ActivatedSignal();
-}
-
-ImfManager::ImfEventSignalV2& ImfManager::EventReceivedSignal()
-{
- return Internal::Adaptor::ImfManager::GetImplementation(*this).EventReceivedSignal();
-}
-
-ImfManager::ImfManager(Internal::Adaptor::ImfManager *impl)
- : BaseHandle(impl)
-{
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/key.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/key-impl.h>
-
-namespace Dali
-{
-
-bool IsKey( const KeyEvent& keyEvent, KEY daliKey)
-{
- return Internal::Adaptor::KeyLookup::IsKey( keyEvent, daliKey );
-}
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/orientation.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/orientation-impl.h>
-
-namespace Dali
-{
-
-Orientation::Orientation()
-{
-}
-
-Orientation::~Orientation()
-{
-}
-
-int Orientation::GetDegrees() const
-{
- return Internal::Adaptor::GetImplementation(*this).GetDegrees();
-}
-
-float Orientation::GetRadians() const
-{
- return Internal::Adaptor::GetImplementation(*this).GetRadians();
-}
-
-Orientation::OrientationSignalV2& Orientation::ChangedSignal()
-{
- return Internal::Adaptor::GetImplementation(*this).ChangedSignal();
-}
-
-Orientation::Orientation( Internal::Adaptor::Orientation* orientation )
-: BaseHandle(orientation)
-{
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <public-api/adaptor-framework/common/physical-keyboard.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/physical-keyboard-impl.h>
-
-namespace Dali
-{
-
-PhysicalKeyboard::PhysicalKeyboard()
-{
-}
-
-PhysicalKeyboard::~PhysicalKeyboard()
-{
-}
-
-PhysicalKeyboard PhysicalKeyboard::Get()
-{
- // Get the physical keyboard handle
- PhysicalKeyboard handle = Internal::Adaptor::PhysicalKeyboard::Get();
-
- // If it's not been created then create one
- if ( !handle )
- {
- handle = Internal::Adaptor::PhysicalKeyboard::New();
- }
-
- return handle;
-}
-
-bool PhysicalKeyboard::IsAttached() const
-{
- return GetImplementation( *this ).IsAttached();
-}
-
-PhysicalKeyboard::Signal& PhysicalKeyboard::StatusChangedSignal()
-{
- return GetImplementation( *this ).StatusChangedSignal();
-}
-
-PhysicalKeyboard::PhysicalKeyboard( Internal::Adaptor::PhysicalKeyboard *impl )
-: BaseHandle(impl)
-{
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_PHYSICAL_KEYBOARD_H__
-#define __DALI_PHYSICAL_KEYBOARD_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class PhysicalKeyboard;
-}
-}
-
-/**
- * This is a handle to a physical keyboard connected to the device.
- */
-class PhysicalKeyboard : public BaseHandle
-{
-public:
-
- typedef SignalV2< void (PhysicalKeyboard) > Signal;
-
-public:
-
- /**
- * Create an uninitialized PhysicalKeyboard handle; this can be initialized with GetKeyboard()
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- PhysicalKeyboard();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~PhysicalKeyboard();
-
- /**
- * Gets a handle to the physical keyboard.
- * @return A handle to the physical keyboard.
- */
- static PhysicalKeyboard Get();
-
- /**
- * Queries whether a physical keyboard is attached or not.
- * @return true if a physical keyboard is attached, false otherwise.
- */
- bool IsAttached() const;
-
- // Signals
-
- /**
- * Emitted when the status of the physical keyboard changes.
- * A callback of the following type may be connected:
- * @code
- * void YourCallbackName(PhysicalKeyboard keyboard);
- * @endcode
- * @pre The PhysicalKeyboard has been initialized.
- * @return The status changed signal.
- */
- Signal& StatusChangedSignal();
-
- // Not intended for application developers
-
- /**
- * Creates a new handle from the implementation.
- * @param[in] impl A pointer to the object.
- */
- explicit DALI_INTERNAL PhysicalKeyboard( Internal::Adaptor::PhysicalKeyboard* impl );
-};
-
-} // namespace Dali
-
-#endif // __DALI_PHYSICAL_KEYBOARD_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/pixmap-image.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/pixmap-image-impl.h>
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/any.h>
-
-namespace Dali
-{
-
-PixmapImagePtr PixmapImage::New(unsigned int width, unsigned int height, ColorDepth depth, Adaptor& adaptor)
-{
- Any empty;
- PixmapImagePtr image = new PixmapImage(width, height, depth, adaptor, empty);
- return image;
-}
-
-PixmapImagePtr PixmapImage::New(Any pixmap, Adaptor& adaptor)
-{
- PixmapImagePtr image = new PixmapImage(0, 0, COLOR_DEPTH_DEFAULT, adaptor, pixmap);
- return image;
-}
-
-Any PixmapImage::GetPixmap(PixmapAPI api)
-{
- return mImpl->GetPixmap(api);
-}
-
-Any PixmapImage::GetDisplay()
-{
- return mImpl->GetDisplay();
-}
-
-bool PixmapImage::GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const
-{
- return mImpl->GetPixels( pixbuf, width, height, pixelFormat );
-}
-
-bool PixmapImage::EncodeToFile(const std::string& filename) const
-{
- return mImpl->EncodeToFile(filename);
-}
-
-bool PixmapImage::GlExtensionCreate()
-{
- return mImpl->GlExtensionCreate();
-}
-
-void PixmapImage::GlExtensionDestroy()
-{
- mImpl->GlExtensionDestroy();
-}
-
-unsigned int PixmapImage::TargetTexture()
-{
- return mImpl->TargetTexture();
-}
-
-void PixmapImage::PrepareTexture()
-{
-
-}
-
-unsigned int PixmapImage::GetWidth() const
-{
- return mImpl->GetWidth();
-}
-
-unsigned int PixmapImage::GetHeight() const
-{
- return mImpl->GetHeight();
-}
-
-Pixel::Format PixmapImage::GetPixelFormat() const
-{
- return mImpl->GetPixelFormat();
-}
-
-PixmapImage::PixmapImage(unsigned int width, unsigned int height, ColorDepth depth, Adaptor& adaptor, Any pixmap)
-{
- mImpl = Internal::Adaptor::PixmapImage::New( width, height, depth, adaptor, pixmap);
-}
-
-PixmapImage::~PixmapImage()
-{
- delete mImpl;
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/render-surface.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/render-surface-impl.h>
-#include <internal/common/ecore-x/pixmap-render-surface.h>
-#include <internal/common/ecore-x/window-render-surface.h>
-
-namespace Dali
-{
-
-RenderSurface::RenderSurface()
-{
-}
-
-RenderSurface::~RenderSurface()
-{
-}
-
-RenderSurface* CreateDefaultSurface( RenderSurface::SurfaceType type, PositionSize positionSize, const std::string& name )
-{
- // create a Ecore X11 window by default
- Any surface;
- Any display;
-
- Internal::Adaptor::ECoreX::RenderSurface* renderSurface(NULL);
- if( RenderSurface::WINDOW == type )
- {
- renderSurface = new Internal::Adaptor::ECoreX::WindowRenderSurface( positionSize, surface, display, name );
- }
- else
- {
- renderSurface = new Internal::Adaptor::ECoreX::PixmapRenderSurface( positionSize, surface, display, name );
- }
-
- return renderSurface;
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/sound-player.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/sound-player-impl.h>
-
-namespace Dali
-{
-
-const char* const SoundPlayer::SIGNAL_SOUND_PLAY_FINISHED = "sound-play-finished";
-
-SoundPlayer::SoundPlayer()
-{
-}
-
-SoundPlayer SoundPlayer::Get()
-{
- return Internal::Adaptor::SoundPlayer::Get();
-}
-
-SoundPlayer::~SoundPlayer()
-{
-}
-
-int SoundPlayer::PlaySound(const std::string fileName)
-{
- return GetImplementation(*this).PlaySound(fileName);
-}
-
-void SoundPlayer::Stop(int handle)
-{
- GetImplementation(*this).Stop(handle);
-}
-
-SoundPlayer::SoundPlayFinishedSignalV2& SoundPlayer::SoundPlayFinishedSignal()
-{
- return GetImplementation(*this).SoundPlayFinishedSignal();
-}
-
-SoundPlayer::SoundPlayer( Internal::Adaptor::SoundPlayer* player )
-: BaseHandle( player )
-{
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/style-monitor.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/style-monitor-impl.h>
-
-namespace Dali
-{
-
-StyleMonitor::StyleMonitor()
-{
-}
-
-StyleMonitor::StyleMonitor(const StyleMonitor& monitor)
-: BaseHandle(monitor)
-{
-}
-
-StyleMonitor StyleMonitor::StyleMonitor::Get()
-{
- return Internal::Adaptor::StyleMonitor::Get();
-}
-
-StyleMonitor::~StyleMonitor()
-{
-}
-
-std::string StyleMonitor::GetDefaultFontFamily() const
-{
- return GetImplementation(*this).GetDefaultFontFamily();
-}
-
-float StyleMonitor::GetDefaultFontSize() const
-{
- return GetImplementation(*this).GetDefaultFontSize();
-}
-
-const std::string& StyleMonitor::GetTheme() const
-{
- return GetImplementation(*this).GetTheme();
-}
-
-void StyleMonitor::SetTheme(const std::string& themFilePath)
-{
- return GetImplementation(*this).SetTheme(themFilePath);
-}
-
-StyleMonitor::StyleChangeSignalV2& StyleMonitor::StyleChangeSignal()
-{
- return GetImplementation(*this).StyleChangeSignal();
-}
-
-StyleMonitor& StyleMonitor::operator=(const StyleMonitor& monitor)
-{
- if( *this != monitor )
- {
- BaseHandle::operator=(monitor);
- }
- return *this;
-}
-
-StyleMonitor::StyleMonitor(Internal::Adaptor::StyleMonitor* internal)
-: BaseHandle(internal)
-{
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "tilt-sensor.h"
-
-// INTERNAL INCLUDES
-#include <internal/common/tilt-sensor-impl.h>
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-
-const char* const TiltSensor::SIGNAL_TILTED = "tilted";
-
-const float TiltSensor::DEFAULT_UPDATE_FREQUENCY = 60.0f;
-
-TiltSensor::TiltSensor()
-{
-}
-
-TiltSensor TiltSensor::Get()
-{
- return Internal::Adaptor::TiltSensor::Get();
-}
-
-TiltSensor::~TiltSensor()
-{
-}
-
-bool TiltSensor::Enable()
-{
- return GetImplementation(*this).Enable();
-}
-
-void TiltSensor::Disable()
-{
- GetImplementation(*this).Disable();
-}
-
-bool TiltSensor::IsEnabled() const
-{
- return GetImplementation(*this).IsEnabled();
-}
-
-float TiltSensor::GetRoll() const
-{
- return GetImplementation(*this).GetRoll();
-}
-
-float TiltSensor::GetPitch() const
-{
- return GetImplementation(*this).GetPitch();
-}
-
-Quaternion TiltSensor::GetRotation() const
-{
- return GetImplementation(*this).GetRotation();
-}
-
-TiltSensor::TiltedSignalV2& TiltSensor::TiltedSignal()
-{
- return GetImplementation(*this).TiltedSignal();
-}
-
-void TiltSensor::SetUpdateFrequency( float frequencyHertz )
-{
- GetImplementation(*this).SetUpdateFrequency( frequencyHertz );
-}
-
-float TiltSensor::GetUpdateFrequency() const
-{
- return GetImplementation(*this).GetUpdateFrequency();
-}
-
-void TiltSensor::SetRotationThreshold(Radian rotationThreshold)
-{
- GetImplementation(*this).SetRotationThreshold( rotationThreshold );
-}
-
-Radian TiltSensor::GetRotationThreshold() const
-{
- return GetImplementation(*this).GetRotationThreshold();
-}
-
-TiltSensor::TiltSensor( Internal::Adaptor::TiltSensor* sensor )
-: BaseHandle( sensor )
-{
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TILT_SENSOR_H__
-#define __DALI_TILT_SENSOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class TiltSensor;
-}
-}
-
-/**
- * TiltSensor provides pitch & roll values when the device is tilted.
- * The basic usage is shown below:
- *
- * @code
- *
- * void Example()
- * {
- * TiltSensor sensor = TiltSensor::Get();
- *
- * // Try to enable the sensor
- * if ( sensor.Enable() )
- * {
- * // Query the current values
- * std::cout << "Roll = " << sensor.GetRoll() << ", Pitch = " << sensor.GetPitch() << std::endl;
- *
- * // Get notifications when the device is tilted
- * sensor.SignalTilted().Connect( &OnTilted );
- * }
- * }
- *
- * void OnTilted()
- * {
- * // Query the new values
- * std::cout << "Roll = " << sensor.GetRoll() << ", Pitch = " << sensor.GetPitch() << std::endl;
- * }
- *
- * @endcode
- *
- * While the tilt sensor is enabled, it will periodically poll for the latest pitch & roll values.
- * For performance & power-saving, applications should disable this polling when no longer needed:
- *
- * @code
- *
- * void EndExample()
- * {
- * // Disable the sensor when no longer needed
- * TiltSensor::Get().Disable();
- * }
- *
- * @endcode
- */
-class TiltSensor : public BaseHandle
-{
-public:
-
- typedef SignalV2< void (const TiltSensor&) > TiltedSignalV2;
-
- // Signal Names
- static const char* const SIGNAL_TILTED;
-
- static const float DEFAULT_UPDATE_FREQUENCY; // 60 hertz
-
- /**
- * Create an uninitialized handle.
- * This can be initialized by calling TiltSensor::Get().
- */
- TiltSensor();
-
- /**
- * Create an initialized handle to the TiltSensor.
- * @return A handle to a newly allocated Dali resource.
- */
- static TiltSensor Get();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~TiltSensor();
-
- /**
- * Attempt to enable the tilt-sensor. This will fail if the underlying sensor hardware is powered-down,
- * typically this occurs when the device is set to "sleep" mode.
- * @return True if the tilt-sensor is enabled.
- */
- bool Enable();
-
- /**
- * Disable the tilt-sensor.
- */
- void Disable();
-
- /**
- * Query whether the tilt-sensor is disabled.
- * The sensor may be disabled automatically; typically this occurs when the device is set to "sleep" mode.
- * @return True if the tilt-sensor is enabled.
- */
- bool IsEnabled() const;
-
- /**
- * Query the roll value. This is in the range -1 to 1.
- * When the device is lying face-up on a flat surface, this method will return a value close to zero.
- * A value close to 1 indicates that the right-side of the device is pointing upwards.
- * A value close to -1 indicates that the right-side of the device is pointing downwards.
- * @pre The tilt-sensor is enabled.
- * @return The roll value.
- */
- float GetRoll() const;
-
- /**
- * Query the pitch value. This is in the range -1 to 1.
- * When the device is lying face-up on a flat surface, this method will return a value close to zero.
- * A value close to 1 indicates that the top of the device is pointing upwards.
- * A value close to -1 indicates that the top of the device is pointing downwards.
- * @pre The tilt-sensor is enabled.
- * @return The pitch value.
- */
- float GetPitch() const;
-
- /**
- * Retrieve the rotation of the device.
- * When the device is lying face-up on a flat surface, the rotation angle will be approximately zero.
- * The roll & pitch of the device is considered to be a rotation around the Y and X axes respectively.
- * @pre The tilt-sensor is enabled.
- * @return The rotation in quaternion format.
- */
- Quaternion GetRotation() const;
-
- /**
- * This signal will be emitted when the device is tilted, if the tilt-sensor is enabled.
- * The frequency of the signals can be controlled using SetUpdateFrequency().
- * @return The signal to connect to.
- */
- TiltedSignalV2& TiltedSignal();
-
- /**
- * Set the sensor update frequency.
- * The default is TiltSensor::DEFAULT_UPDATE_FREQUENCY.
- * @param[in] frequencyHertz The frequency in hertz.
- */
- void SetUpdateFrequency( float frequencyHertz );
-
- /**
- * Query the sensor update frequency.
- * @return The frequency in hertz.
- */
- float GetUpdateFrequency() const;
-
- /**
- * Set the threshold value for rotation in Radians, above which TiltedSignal should be emitted.
- * The default is 0.0f in Radians (i.e) it will be emitted always at the frequency set.
- * Example tiltSensor.SetRotationThreshold( Radian(Degree(10) ) // A rotation threshold of 10 degrees
- * @param[in] rotationThreshold The threshold value for rotation.
- */
- void SetRotationThreshold( Radian rotationThreshold );
-
- /**
- * Query the rotation threshold above which TiltedSignal will be emitted.
- * @return The rotation degree threshold in Radians.
- */
- Radian GetRotationThreshold() const;
-
-public: // Not intended for application developers
-
- /**
- * This constructor is used by TiltSensor::Get().
- * @param[in] sensor A pointer to the tilt sensor.
- */
- TiltSensor( Internal::Adaptor::TiltSensor* sensor );
-};
-
-} // namespace Dali
-
-#endif // __DALI_TILT_SENSOR_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/timer.h>
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/timer-impl.h>
-
-namespace Dali
-{
-
-Timer::Timer()
-{
-}
-
-Timer Timer::New( unsigned int milliSec )
-{
- Internal::Adaptor::TimerPtr internal = Internal::Adaptor::Timer::New( milliSec );
- return Timer(internal.Get());
-}
-
-Timer::Timer( const Timer& timer )
-: BaseHandle(timer)
-{
-}
-
-Timer& Timer::operator=( const Timer& timer )
-{
- // check self assignment
- if( *this != timer )
- {
- BaseHandle::operator=(timer);
- }
- return *this;
-}
-
-Timer::~Timer()
-{
-}
-
-void Timer::Start()
-{
- Internal::Adaptor::GetImplementation(*this).Start();
-}
-
-void Timer::Stop()
-{
- Internal::Adaptor::GetImplementation(*this).Stop();
-}
-
-void Timer::SetInterval( unsigned int interval )
-{
- Internal::Adaptor::GetImplementation(*this).SetInterval( interval );
-}
-
-unsigned int Timer::GetInterval() const
-{
- return Internal::Adaptor::GetImplementation(*this).GetInterval();
-}
-
-bool Timer::IsRunning() const
-{
- return Internal::Adaptor::GetImplementation(*this).IsRunning();
-}
-
-Timer::TimerSignalV2& Timer::TickSignal()
-{
- return Internal::Adaptor::GetImplementation(*this).TickSignal();
-}
-
-Timer::Timer(Internal::Adaptor::Timer* timer)
-: BaseHandle(timer)
-{
-}
-
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/tts-player.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/tts-player-impl.h>
-#include <internal/common/adaptor-impl.h>
-
-namespace Dali
-{
-
-TtsPlayer::TtsPlayer()
-{
-}
-
-TtsPlayer TtsPlayer::Get(Dali::TtsPlayer::Mode mode)
-{
- TtsPlayer ttsPlayer;
-
- if ( Adaptor::IsAvailable() )
- {
- ttsPlayer = Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).GetTtsPlayer(mode);
- }
-
- return ttsPlayer;
-}
-
-TtsPlayer::~TtsPlayer()
-{
-}
-
-void TtsPlayer::Play(const std::string& text)
-{
- return GetImplementation(*this).Play(text);
-}
-
-void TtsPlayer::Stop()
-{
- GetImplementation(*this).Stop();
-}
-
-void TtsPlayer::Pause()
-{
- GetImplementation(*this).Pause();
-}
-
-void TtsPlayer::Resume()
-{
- GetImplementation(*this).Resume();
-}
-
-TtsPlayer::TtsPlayer( Internal::Adaptor::TtsPlayer* player )
-: BaseHandle( player )
-{
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/virtual-keyboard.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/virtual-keyboard-impl.h>
-
-namespace Dali
-{
-
-namespace VirtualKeyboard
-{
-
-void Show()
-{
- Internal::Adaptor::VirtualKeyboard::Show();
-}
-
-void Hide()
-{
- Internal::Adaptor::VirtualKeyboard::Hide();
-}
-
-bool IsVisible()
-{
- return Internal::Adaptor::VirtualKeyboard::IsVisible();
-}
-
-void SetReturnKeyType( ReturnKeyType type )
-{
- Internal::Adaptor::VirtualKeyboard::SetReturnKeyType( type );
-}
-
-ReturnKeyType GetReturnKeyType()
-{
- return Internal::Adaptor::VirtualKeyboard::GetReturnKeyType();
-}
-
-void EnablePrediction(const bool enable)
-{
- Internal::Adaptor::VirtualKeyboard::EnablePrediction(enable);
-}
-
-bool IsPredictionEnabled()
-{
- return Internal::Adaptor::VirtualKeyboard::IsPredictionEnabled();
-}
-
-Rect<int> GetSizeAndPosition()
-{
- return Internal::Adaptor::VirtualKeyboard::GetSizeAndPosition();
-}
-
-void RotateTo(int angle)
-{
- Internal::Adaptor::VirtualKeyboard::RotateTo(angle);
-}
-
-StatusSignalV2& StatusChangedSignal()
-{
- return Internal::Adaptor::VirtualKeyboard::StatusChangedSignal();
-}
-
-VoidSignalV2& ResizedSignal()
-{
- return Internal::Adaptor::VirtualKeyboard::ResizedSignal();
-}
-
-VoidSignalV2& LanguageChangedSignal()
-{
- return Internal::Adaptor::VirtualKeyboard::LanguageChangedSignal();
-}
-
-TextDirection GetTextDirection()
-{
- return Internal::Adaptor::VirtualKeyboard::GetTextDirection();
-}
-
-} // namespace VirtualKeyboard
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/common/window.h>
-
-// INTERNAL INCLUDES
-#include <internal/common/window-impl.h>
-#include <internal/common/orientation-impl.h>
-
-namespace Dali
-{
-
-Window Window::New(PositionSize posSize, const std::string name, bool isTransparent)
-{
- Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, isTransparent);
- return Window(window);
-}
-
-Window::Window()
-{
-}
-
-Window::~Window()
-{
-}
-
-void Window::SetIndicatorStyle( IndicatorStyle style )
-{
- GetImplementation(*this).SetIndicatorStyle( style );
-}
-
-void Window::ShowIndicator( bool show )
-{
- GetImplementation(*this).ShowIndicator( show );
-}
-
-void Window::ShowIndicator( IndicatorVisibleMode visibleMode )
-{
- GetImplementation(*this).ShowIndicator( visibleMode );
-}
-
-void Window::SetIndicatorBgOpacity( IndicatorBgOpacity opacity )
-{
- GetImplementation(*this).SetIndicatorBgOpacity( opacity );
-}
-
-void Window::RotateIndicator( WindowOrientation orientation )
-{
- GetImplementation(*this).RotateIndicator( orientation );
-}
-
-void Window::SetClass( std::string name, std::string klass )
-{
- GetImplementation(*this).SetClass( name, klass );
-}
-
-void Window::Raise()
-{
- GetImplementation(*this).Raise();
-}
-
-void Window::Lower()
-{
- GetImplementation(*this).Lower();
-}
-
-void Window::Activate()
-{
- GetImplementation(*this).Activate();
-}
-
-Orientation Window::GetOrientation()
-{
- Internal::Adaptor::OrientationPtr orientation = GetImplementation(*this).GetOrientation();
- return Orientation(orientation.Get());
-}
-
-void Window::AddAvailableOrientation( WindowOrientation orientation )
-{
- GetImplementation(*this).AddAvailableOrientation( orientation );
-}
-
-void Window::RemoveAvailableOrientation( WindowOrientation orientation )
-{
- GetImplementation(*this).RemoveAvailableOrientation( orientation );
-}
-
-void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
-{
- GetImplementation(*this).SetAvailableOrientations( orientations );
-}
-
-const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
-{
- return GetImplementation(*this).GetAvailableOrientations();
-}
-
-void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
-{
- GetImplementation(*this).SetPreferredOrientation( orientation );
-}
-
-Dali::Window::WindowOrientation Window::GetPreferredOrientation()
-{
- return GetImplementation(*this).GetPreferredOrientation();
-}
-
-DragAndDropDetector Window::GetDragAndDropDetector() const
-{
- return GetImplementation(*this).GetDragAndDropDetector();
-}
-
-Window::Window( Internal::Adaptor::Window* window )
-: BaseHandle( window )
-{
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "livebox-plugin.h"
-
-// EXTERNAL INCLUDES
-
-// INTERNAL INCLUDES
-#include <internal/livebox-plugin-impl.h>
-
-namespace Dali
-{
-
-LiveboxPlugin::LiveboxPlugin( int* argc, char **argv[] )
-{
- mImpl = new Internal::Adaptor::LiveboxPlugin(*this, argc, argv, "Dali Livebox", DeviceLayout::DEFAULT_BASE_LAYOUT);
-}
-
-LiveboxPlugin::LiveboxPlugin( int* argc, char **argv[], const std::string& name )
-{
- mImpl = new Internal::Adaptor::LiveboxPlugin(*this, argc, argv, name, DeviceLayout::DEFAULT_BASE_LAYOUT);
-}
-
-LiveboxPlugin::LiveboxPlugin(int* argc, char **argv[], const DeviceLayout& baseLayout)
-{
- mImpl = new Internal::Adaptor::LiveboxPlugin(*this, argc, argv, "Dali Livebox", baseLayout);
-}
-
-LiveboxPlugin::LiveboxPlugin(int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout)
-{
- mImpl = new Internal::Adaptor::LiveboxPlugin(*this, argc, argv, name, baseLayout);
-}
-
-LiveboxPlugin::~LiveboxPlugin()
-{
- delete mImpl;
-}
-
-void LiveboxPlugin::SetTitle(const std::string& title)
-{
- mImpl->SetTitle(title);
-}
-
-void LiveboxPlugin::SetContent(const std::string& content)
-{
- mImpl->SetContent(content);
-}
-
-const PositionSize& LiveboxPlugin::GetGlanceBarGeometry() const
-{
- return mImpl->GetGlanceBarGeometry();
-}
-
-const GlanceBarEventInfo& LiveboxPlugin::GetGlanceBarEventInfo() const
-{
- return mImpl->GetGlanceBarEventInfo();
-}
-
-LiveboxSizeType LiveboxPlugin::GetLiveboxSizeType() const
-{
- return mImpl->GetLiveboxSizeType();
-}
-
-void LiveboxPlugin::Run()
-{
- mImpl->Run();
-}
-
-void LiveboxPlugin::Quit()
-{
- mImpl->Quit();
-}
-
-bool LiveboxPlugin::AddIdle(boost::function<void(void)> callBack)
-{
- return mImpl->AddIdle(callBack);
-}
-
-LiveboxPlugin& LiveboxPlugin::Get()
-{
- return Internal::Adaptor::LiveboxPlugin::Get();
-}
-
-LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::InitializedSignal()
-{
- return mImpl->InitializedSignal();
-}
-
-LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::TerminatedSignal()
-{
- return mImpl->TerminatedSignal();
-}
-
-LiveboxPlugin::LiveboxPluginSignal LiveboxPlugin::SignalTerminated()
-{
- return mImpl->SignalTerminated();
-}
-
-LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::PausedSignal()
-{
- return mImpl->PausedSignal();
-}
-
-LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::ResumedSignal()
-{
- return mImpl->ResumedSignal();
-}
-LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::ResizedSignal()
-{
- return mImpl->ResizedSignal();
-}
-
-LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::GlanceCreatedSignal()
-{
- return mImpl->GlanceCreatedSignal();
-}
-
-LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::GlanceDestroyedSignal()
-{
- return mImpl->GlanceDestroyedSignal();
-}
-
-LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::GlanceTouchedSignal()
-{
- return mImpl->GlanceTouchedSignal();
-}
-
-LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::GlanceMovedSignal()
-{
- return mImpl->GlanceMovedSignal();
-}
-
-LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::GlanceScriptEventSignal()
-{
- return mImpl->GlanceScriptEventSignal();
-}
-
-LiveboxPlugin::LiveboxPluginSignalV2& LiveboxPlugin::LanguageChangedSignal()
-{
- return mImpl->LanguageChangedSignal();
-}
-
-} // namespace Dali
-
+++ /dev/null
-#ifndef __DALI_LIVEBOX_H__
-#define __DALI_LIVEBOX_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDS
-#include <boost/function.hpp>
-#include <string>
-#include <dali/public-api/math/rect.h>
-
-// INTERNAL INCLUDES
-#include "common/device-layout.h"
-#include "common/style-monitor.h"
-
-
-namespace Dali DALI_IMPORT_API
-{
-typedef Dali::Rect<int> PositionSize;
-
-/**
-* Livebox's size types
-* It refers "livebox-service.h"
-*/
-enum LiveboxSizeType
-{
- LIVEBOX_SIZE_TYPE_1x1 = 0x0001,
- LIVEBOX_SIZE_TYPE_2x1 = 0x0002,
- LIVEBOX_SIZE_TYPE_2x2 = 0x0004,
- LIVEBOX_SIZE_TYPE_4x1 = 0x0008,
- LIVEBOX_SIZE_TYPE_4x2 = 0x0010,
- LIVEBOX_SIZE_TYPE_4x3 = 0x0020,
- LIVEBOX_SIZE_TYPE_4x4 = 0x0040,
- LIVEBOX_SIZE_TYPE_EASY_1x1 = 0x0100,
- LIVEBOX_SIZE_TYPE_EASY_3x1 = 0x0200,
- LIVEBOX_SIZE_TYPE_EASY_3x3 = 0x0400,
- LIVEBOX_SIZE_TYPE_UNKNOWN = 0xFFFF,
-};
-
-struct GlanceBarEventInfo
-{
- std::string emission;
- std::string source;
-
- struct
- {
- double x;
- double y;
- int down;
- } pointer; ///< touch information for script
-
- struct
- {
- double sx;
- double sy;
- double ex;
- double ey;
- } part; ///<part information for script
-};
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-
-class LiveboxPlugin;
-}
-}
-
-/**
- * An LiveboxPlugin class object should be created by every livebox
- * that wishes to use Dali. It provides a means for initialising the
- * resources required by the Dali::Core.
- *
- * The LiveboxPlugin class emits several signals which the user can
- * connect to. The user should not create any Dali objects in the main
- * function and instead should connect to the Init signal of the
- * LiveboxPlugin and create the Dali objects in the connected callback.
- *
- * SLP and Linux Liveboxs should follow the example below:
- *
- * @code
- * void CreateProgram(LiveboxPlugin& livebox)
- * {
- * // Create Dali components...
- * // Can instantiate here, if required
- * }
- *
- * int main (int argc, char **argv)
- * {
- * LiveboxPlugin livebox(&argc, &argv);
- * livebox.InitSignal().Connect(&CreateProgram);
- * livebox.Run();
- * }
- * @endcode
- *
- * If required, you can also connect class member functions to a signal:
- *
- * @code
- * MyLivebox livebox;
- * livebox.SignalResumed().Connect(&app, &MyLivebox::OnResumed);
- * @endcode
- */
-class LiveboxPlugin
-{
-public:
-
- typedef SignalV2< void (LiveboxPlugin&) > LiveboxPluginSignalV2;
-
-public:
-
- /**
- * This is the constructor for Linux & SLP liveboxs.
- * @param argc A pointer to the number of arguments
- * @param argv A pointer the the argument list
- * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
- */
- LiveboxPlugin( int* argc, char **argv[] );
-
- /**
- * This is the constructor for Linux & SLP liveboxs with a name
- * @param argc A pointer to the number of arguments
- * @param argv A pointer the the argument list
- * @param name A name of livebox
- * @note The default base layout (DeviceLayout::DEFAULT_BASE_LAYOUT) will be used with this constructor.
- */
- LiveboxPlugin( int* argc, char **argv[], const std::string& name );
-
- /**
- * This is the constructor for Linux & SLP liveboxs when a layout for the livebox is specified.
- * @param argc A pointer to the number of arguments
- * @param argv A pointer the the argument list
- * @param baseLayout The base layout that the livebox has been written for
- */
- LiveboxPlugin( int* argc, char **argv[], const DeviceLayout& baseLayout );
-
- /**
- * This is the constructor for Linux & SLP liveboxs with a name and when a layout for the livebox is specified.
- * @param argc A pointer to the number of arguments
- * @param argv A pointer the the argument list
- * @param name A name of livebox
- * @param baseLayout The base layout that the livebox has been written for
- */
- LiveboxPlugin( int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout );
-
- /**
- * Virtual destructor
- */
- virtual ~LiveboxPlugin();
-
-public:
-
- /**
- * Set title string of the livebox
- * @param[in] title title string
- */
- void SetTitle(const std::string& title);
-
- /**
- * Set content string of the livebox
- * @param[in] content content string
- */
- void SetContent(const std::string& content);
-
- /**
- * Get glance bar's geometry information
- * x, y mean arrow position
- * w, h mean glance size
- * User can use this method in the glance-created signal handler
- * @return PositionSize structure for glance bar information. {-1, -1, -1, -1} means invalid status for glance
- */
- const PositionSize& GetGlanceBarGeometry() const;
-
- /**
- * Get glance bar's event information
- * @return GlanceBarEventInfo structure for glance bar event
- */
- const GlanceBarEventInfo& GetGlanceBarEventInfo() const;
-
- /**
- * Get current size type of livebox
- */
- LiveboxSizeType GetLiveboxSizeType() const;
-
- /**
- * This starts the livebox providing.
- */
- void Run();
-
- /**
- * This quits the livebox providing.
- */
- void Quit();
-
- /**
- * Ensures that the function passed in is called from the main loop when it is idle.
- *
- * A callback of the following type may be used:
- * @code
- * void MyFunction();
- * @endcode
- *
- * @param[in] callBack The function to call.
- * @return true if added successfully, false otherwise
- */
- bool AddIdle(boost::function<void(void)> callBack);
-
- /**
- * Returns the local thread's instance of the LiveboxPlugin class.
- * @return A reference to the local thread's LiveboxPlugin class instance.
- * @pre The LiveboxPlugin class has been initialised.
- * @note This is only valid in the main thread.
- */
- static LiveboxPlugin& Get();
-
-public: // Signals
-
- /**
- * The user should connect to this signal to determine when they should initialise
- * their livebox
- */
- LiveboxPluginSignalV2& InitializedSignal();
-
- /**
- * The user should connect to this signal to determine when they should terminate
- * their livebox
- */
- LiveboxPluginSignalV2& TerminatedSignal();
-
- /**
- * The user should connect to this signal if they need to perform any special
- * activities when the livebox is about to be paused.
- */
- LiveboxPluginSignalV2& PausedSignal();
-
- /**
- * The user should connect to this signal if they need to perform any special
- * activities when the livebox has resumed.
- */
- LiveboxPluginSignalV2& ResumedSignal();
-
- /**
- * This signal is emitted when the surface the livebox is rendering on is resized.
- */
- LiveboxPluginSignalV2& ResizedSignal();
-
- /**
- * This signal is emitted when the glance bar popup was created.
- */
- LiveboxPluginSignalV2& GlanceCreatedSignal();
-
- /**
- * This signal is emitted when the glance bar popup was destroyed.
- */
- LiveboxPluginSignalV2& GlanceDestroyedSignal();
-
- /**
- * This signal is emitted when the glance bar popup was touched.
- */
- LiveboxPluginSignalV2& GlanceTouchedSignal();
-
- /**
- * This signal is emitted when the glance bar popup was moved.
- */
- LiveboxPluginSignalV2& GlanceMovedSignal();
-
- /**
- * This signal is emitted when the glance bar popup was got script event callback.
- * If application registered the edje file for glance bar,
- * this signal will be emitted instead of SignalGlanceTouched.
- * Application can get the event information by using GetGlanceBarEventInfo()
- */
- LiveboxPluginSignalV2& GlanceScriptEventSignal();
-
- /**
- * This signal is emitted when the language is changed on the device.
- */
- LiveboxPluginSignalV2& LanguageChangedSignal();
-
-private:
-
- // Undefined
- LiveboxPlugin(const LiveboxPlugin&);
- LiveboxPlugin& operator=(const LiveboxPlugin&);
-
-private:
-
- Internal::Adaptor::LiveboxPlugin *mImpl;
- friend class Internal::Adaptor::LiveboxPlugin;
-};
-
-} // namespace Dali
-
-#endif // __DALI_LIVEBOX_H__
-
+++ /dev/null
-# Public source files
-tizen_evas_plugin_public_api_src_files = \
- $(tizen_evas_plugin_public_api_src_dir)/adaptor-framework/mobile/evas-plugin.cpp
-
-tizen_native_buffer_plugin_public_api_src_files = \
- $(tizen_native_buffer_plugin_public_api_src_dir)/adaptor-framework/mobile/native-buffer-plugin.cpp
-
-#tizen_evas_plugin_public_api_header_files =
-# EXPORTED IN CAPI
-# $(tizen_evas_plugin_public_api_src_dir)/adaptor-framework/evas-plugin.h
-
-#tizen_native_buffer_plugin_public_api_header_files =
-# EXPORTED IN CAPI
-# $(tizen_native_buffer_plugin_public_api_src_dir)/adaptor-framework/native-buffer-plugin.h
-
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/evas-plugin.h>
-
-// EXTERNAL INCLUDES
-
-// INTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-
-#include <internal/mobile/evas-plugin-impl.h>
-
-namespace Dali
-{
-
-EvasPlugin::EvasPlugin(Evas_Object* parent, bool isTransparent, unsigned int initialWidth, unsigned int initialHeight)
-{
- mImpl = new Internal::Adaptor::EvasPlugin(*this, parent, isTransparent, initialWidth, initialHeight);
-}
-
-EvasPlugin::~EvasPlugin()
-{
- delete mImpl;
-}
-
-void EvasPlugin::Run()
-{
- mImpl->Run();
-}
-
-void EvasPlugin::Pause()
-{
- mImpl->Pause();
-}
-
-void EvasPlugin::Resume()
-{
- mImpl->Resume();
-}
-
-void EvasPlugin::Stop()
-{
- mImpl->Stop();
-}
-
-Evas_Object* EvasPlugin::GetEvasImageObject()
-{
- return mImpl->GetEvasImageObject();
-}
-
-Evas_Object* EvasPlugin::GetElmAccessObject()
-{
- return mImpl->GetElmAccessObject();
-}
-
-Evas_Object* EvasPlugin::GetElmFocusObject()
-{
- return mImpl->GetElmFocusObject();
-}
-
-Dali::Adaptor* EvasPlugin::GetAdaptor()
-{
- return mImpl->GetAdaptor();
-}
-
-EvasPlugin::EvasPluginSignalV2& EvasPlugin::InitSignal()
-{
- return mImpl->InitSignal();
-}
-
-EvasPlugin::EvasPluginSignalV2& EvasPlugin::FirstRenderCompletedSignal()
-{
- return mImpl->FirstRenderCompletedSignal();
-}
-
-EvasPlugin::EvasPluginSignalV2& EvasPlugin::TerminateSignal()
-{
- return mImpl->TerminateSignal();
-}
-
-EvasPlugin::EvasPluginSignalV2& EvasPlugin::PauseSignal()
-{
- return mImpl->PauseSignal();
-}
-
-EvasPlugin::EvasPluginSignalV2& EvasPlugin::ResumeSignal()
-{
- return mImpl->ResumeSignal();
-}
-
-EvasPlugin::EvasPluginSignalV2& EvasPlugin::ResizeSignal()
-{
- return mImpl->ResizeSignal();
-}
-
-EvasPlugin::EvasPluginSignalV2& EvasPlugin::FocusedSignal()
-{
- return mImpl->FocusedSignal();
-}
-
-EvasPlugin::EvasPluginSignalV2& EvasPlugin::UnFocusedSignal()
-{
- return mImpl->UnFocusedSignal();
-}
-
-/**
- * @copydoc ConnectionTrackerInterface::SignalConnected
- */
-void EvasPlugin::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
-{
- mImpl->SignalConnected(slotObserver, callback );
-}
-
-/**
- * @copydoc ConnectionTrackerInterface::SignalDisconnected
- */
-void EvasPlugin::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback )
-{
- mImpl->SignalDisconnected(slotObserver, callback );
-}
-
-/**
- * @copydoc ConnectionTrackerInterface::GetConnectionCount
- */
-std::size_t EvasPlugin::GetConnectionCount() const
-{
- return mImpl->GetConnectionCount( );
-}
-
-} // namespace Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/public-api/adaptor-framework/native-buffer-plugin.h>
-
-// EXTERNAL INCLUDES
-
-// INTERNAL INCLUDES
-#include <internal/mobile/native-buffer-plugin-impl.h>
-
-namespace Dali
-{
-
-NativeBufferPlugin::NativeBufferPlugin( unsigned int initialWidth, unsigned int initialHeight, bool isTransparent, unsigned int maxBufferCount, RenderSurface::RenderMode mode, const DeviceLayout& baseLayout )
-{
- mImpl = new Internal::Adaptor::NativeBufferPlugin( *this, initialWidth, initialHeight, isTransparent, maxBufferCount, mode, baseLayout );
-}
-
-NativeBufferPlugin::~NativeBufferPlugin()
-{
- delete mImpl;
-}
-
-void NativeBufferPlugin::Run()
-{
- mImpl->Run();
-}
-
-void NativeBufferPlugin::Pause()
-{
- mImpl->Pause();
-}
-
-void NativeBufferPlugin::Resume()
-{
- mImpl->Resume();
-}
-
-void NativeBufferPlugin::Stop()
-{
- mImpl->Stop();
-}
-
-Dali::Adaptor* NativeBufferPlugin::GetAdaptor()
-{
- return mImpl->GetAdaptor();
-}
-
-native_buffer* NativeBufferPlugin::GetNativeBufferFromOutput()
-{
- return mImpl->GetNativeBufferFromOutput();
-}
-
-bool NativeBufferPlugin::AddNativeBufferToInput(native_buffer* nativeBuffer)
-{
- return mImpl->AddNativeBufferToInput(nativeBuffer);
-}
-
-void NativeBufferPlugin::ChangeSurfaceSize(unsigned int width, unsigned int height)
-{
- mImpl->ChangeSurfaceSize(width, height);
-}
-
-Vector2 NativeBufferPlugin::GetBufferCount()
-{
- return mImpl->GetBufferCount();
-}
-
-NativeBufferPlugin::NativeBufferPluginSignalV2& NativeBufferPlugin::InitSignal()
-{
- return mImpl->InitSignal();
-}
-
-NativeBufferPlugin::NativeBufferPluginSignalV2& NativeBufferPlugin::TerminateSignal()
-{
- return mImpl->TerminateSignal();
-}
-
-NativeBufferPlugin::NativeBufferPluginSignalV2& NativeBufferPlugin::PauseSignal()
-{
- return mImpl->PauseSignal();
-}
-
-NativeBufferPlugin::NativeBufferPluginSignalV2& NativeBufferPlugin::ResumeSignal()
-{
- return mImpl->ResumeSignal();
-}
-
-NativeBufferPlugin::NativeBufferPluginSignalV2& NativeBufferPlugin::FirstRenderCompletedSignal()
-{
- return mImpl->FirstRenderCompletedSignal();
-}
-
-NativeBufferPlugin::NativeBufferPluginSignalV2& NativeBufferPlugin::RenderSignal()
-{
- return mImpl->RenderSignal();
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_H__
-#define __DALI_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/public-api/dali-core.h>
-#include <dali/public-api/dali-adaptor-capi-internal.h>
-
-// Application / UI Framework adaption
-
-// These defines come from running pkg-config --cflags with the correct package config file
-
-#if defined(DALI_LIVEBOX_PLUGIN)
-#include <dali/public-api/adaptor-framework/livebox-plugin.h>
-#endif
-
-#if defined(DALI_APPLICATION)
-#include <dali/public-api/adaptor-framework/application.h>
-#endif
-
-#include <dali/public-api/adaptor-framework/common/accessibility-action-handler.h>
-#include <dali/public-api/adaptor-framework/common/accessibility-gesture-handler.h>
-#include <dali/public-api/adaptor-framework/common/event-feeder.h>
-#include <dali/public-api/adaptor-framework/common/color-controller.h>
-#include <dali/public-api/adaptor-framework/common/feedback-plugin.h>
-#include <dali/public-api/adaptor-framework/common/physical-keyboard.h>
-#include <dali/public-api/adaptor-framework/common/tilt-sensor.h>
-
-#endif //__DALI_H__
+++ /dev/null
-# Add local source files here
-
-tizen_adaptor_public_api_src_files = \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/accessibility-manager.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/adaptor.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/clipboard.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/clipboard-event-notifier.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/color-controller.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/device-layout.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/drag-and-drop-detector.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/event-feeder.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/haptic-player.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/imf-manager.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/key.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/orientation.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/physical-keyboard.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/pixmap-image.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/render-surface.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/sound-player.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/style-monitor.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/tilt-sensor.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/timer.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/tts-player.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/virtual-keyboard.cpp \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/window.cpp
-
-tizen_adaptor_public_api_common_header_files = \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/accessibility-action-handler.h \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/accessibility-gesture-handler.h \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/color-controller.h \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/event-feeder.h \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/feedback-plugin.h \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/physical-keyboard.h \
- $(tizen_adaptor_public_api_src_dir)/adaptor-framework/common/tilt-sensor.h
-
-tizen_adaptor_dali_header_file = \
- $(tizen_adaptor_public_api_src_dir)/dali.h
+++ /dev/null
-#!/bin/bash
-# Log resource analyser tool for Dali
-# Monitors resource usage of last run Dali app
-# Shows memory uploaded to GPU or normal RAM
-# Texture atlas usage usually reflects used Font atlases
-
-set -u
-
-#global variables
-TERM_W=0 # latest width of terminal window
-TERM_H=0 # latest height of terminal window
-SEPARATOR_H=5 # 5 lines in info bar
-CURPAGE=0 # current page number
-MAXFILENO=0 # maximum lines to display from resourcelist
-MAXP=0 # number of pages
-
-DLOGTEMPFILE=/tmp/dalidlog.txt
-DLOGUTIL=/usr/bin/dlogutil
-USING_DLOG=
-INPUTFILE=""
-
-
-
-#possible states
-# ID| Desc | Color | Tags
-#---+----------------------------------+-----------+-------
-# 0.| loaded in CPU memory | [CPU] | [LOAD]
-# 1.| present in both memories | [CPUGPU] | [LOAD] [UPLOAD]
-# 2.| GPU memory only, buffer discarded| [GPU] | [UPLOAD] [DELBUF]
-# 3.| loaded but discarded later on | [DISC] | [LOAD] [DELBUF] or [DELBUF] [DELTEXTURE]
-
-#colors for marking resource state
-COLOR_CPU=5
-COLOR_CPUGPU=1
-COLOR_GPU=2
-COLOR_DISC=6
-
-declare -a COLORS=( $COLOR_CPU $COLOR_CPUGPU $COLOR_GPU $COLOR_DISC )
-
-declare -a FILENAMES_G=( )
-declare -a BITMAPS_G=( )
-declare -a TEXTURES_G=( )
-declare -a STATES_G=( )
-declare -a SIZES_G=( )
-declare -a SIZE_DETAILS_G=( )
-
-ATLASMEM=0
-ATLAS_NO=0
-
-CPUMEM=0
-GPUMEM=0
-
-#process ID of last running Dali app
-PID_G=0
-
-#distinguish texture atlases from framebuffer textures
-BITMAP_ID_ATLAS=0
-BITMAP_ID_FB_TEXTURE="-"
-
-###################################string formatting, command line and error handling
-function error
-{
- echo "Error: $1"
- cleanup
- exit 1
-}
-
-function usage
-{
- echo "usage: ./dalireslog.sh [FILE]"
- echo "if FILE isn't specified script will try to use dlogutil"
-}
-
-function getTermSize
-{
- TERM_W=$(tput cols)
- TERM_H=$(tput lines)
-
- let MAXFILENO=$(($TERM_H-$SEPARATOR_H-2)) #leave space for keyboard shortcuts and separator itself
- let MAXP=${#FILENAMES_G[@]}/$MAXFILENO
-
- # don't show empty page if list just fits on screen
- local rmd=0
- let rmd=${#FILENAMES_G[@]}%$MAXFILENO
- if [ $rmd -eq 0 ]
- then
- let MAXP-=1;
- fi
-}
-
-# print string, notifying user if it doesn't fit in one line. takes one parameter
-function printString
-{
- echo -n ${1:0:$TERM_W}
- if [[ $TERM_W -lt ${#1} ]]
- then
- tput cub 1;
- tput setab 1; tput smso; echo -n '>'; tput el; tput rmso
- return 1
- else
- tput el
- return 0
- fi
-}
-
-# print string, clear until end of line, print newline. takes one parameter
-function printLine
-{
- printString "$1"
- local RET=$?
- printf '\n'
- return $RET
-}
-
-function parseCmdLine
-{
- if [[ $# -lt 1 ]]
- then
- # try using dlogutil
- if [[ ! -e "$DLOGUTIL" ]]
- then
- echo "dlogutil not installed"
- usage
- exit 1
- fi
-
- INPUTFILE="$DLOGTEMPFILE"
- USING_DLOG=true
- else
- # check if help is requested
- if [[ $1 == '-h' || $1 == '--help' ]]
- then
- usage
- exit 0
- # try reading from file
- else
- INPUTFILE=$1
- if [[ ! -e "$INPUTFILE" ]]
- then
- echo cannot read file "$INPUTFILE"
- usage
- exit 1
- fi
- fi
- fi
-}
-
-# print filename or basename or "..." depending on terminal size, takes one parameter
-function printPath
-{
- if [ -z "$1" ]
- then
- echo "ERROR in printPath";
- cleanup; exit 1
- fi
-
- FILENAME="$1"
- FBASENAME=$(basename $FILENAME)
- if [[ ${#FILENAME} -lt $TERM_W ]]
- then
- printLine "$FILENAME"
- else
- if [[ ${#FBASENAME} -lt $TERM_W ]]
- then
- printLine "$FBASENAME"
- else
- printLine ...
- fi
- fi
-}
-
-###################################memory query functions
-function getGpuMemUsage
-{
- GPUMEM=0
- local i=0
- for state in ${STATES_G[@]}
- do
- if [[ $state == 1 || $state == 2 ]]
- then
- let GPUMEM+=${SIZES_G[$i]}
- fi
- let i+=1
- done
- return $GPUMEM
-}
-
-function getCpuMemUsage
-{
- CPUMEM=0
- local i=0
- for state in ${STATES_G[@]}
- do
- if [[ $state == 0 || $state == 1 ]]
- then
- let CPUMEM+=${SIZES_G[$i]}
- fi
- let i+=1
- done
- return $CPUMEM
-}
-
-function getAtlasNumber
-{
- ATLAS_NO=0
- local i=0
- for bitmap in ${BITMAPS_G[@]}
- do
- if [[ $bitmap == 0 && ${STATES_G[$i]} == 2 ]]
- then
- let ATLAS_NO+=1
- fi
- let i+=1
- done
- return $ATLAS_NO
-}
-
-function getAtlasMemUsage
-{
- ATLASMEM=0
- local i=0
- for bitmap in ${BITMAPS_G[@]}
- do
- if [[ $bitmap == 0 && ${STATES_G[$i]} == 2 ]]
- then
- let ATLASMEM+=${SIZES_G[$i]}
- fi
- let i+=1
- done
- return $ATLASMEM
-}
-
-##################################global arrays manipulation
-#adds record to resource list
-#params: filename, bitmap, texture, state, size, size detail
-function addRecord
-{
- if [ $# -ne 6 ]
- then
- error "addRecord - number of arguments is $#"
- fi
- FILENAMES_G+=("$1")
- BITMAPS_G+=("$2")
- TEXTURES_G+=("$3")
- STATES_G+=("$4")
- SIZES_G+=("$5")
- SIZE_DETAILS_G+=("$6")
-}
-
-#adds image resource to list
-#params: filename, bitmap, size, size detail
-function fileLoaded
-{
- if [ $# -ne 4 ]
- then
- error "fileLoaded"
- fi
- FILENAMES_G+=("$1")
- BITMAPS_G+=("$2")
- SIZES_G+=("$3")
- SIZE_DETAILS_G+=("$4")
- TEXTURES_G+=(0)
- STATES_G+=(0)
-}
-
-#params: texture, size, size detail
-function atlasUploaded
-{
- FILENAMES_G+=("-")
- BITMAPS_G+=("$BITMAP_ID_ATLAS")
- TEXTURES_G+=("$1")
- STATES_G+=(2)
- SIZES_G+=("$2")
- SIZE_DETAILS_G+=("$3")
-}
-
-#params: size, size detail
-function frameBufUploaded
-{
- FILENAMES_G+=("$1")
- BITMAPS_G+=("$BITMAP_ID_FB_TEXTURE")
- TEXTURES_G+=("$2")
- STATES_G+=(2)
- SIZES_G+=("$3")
- SIZE_DETAILS_G+=("$4")
-}
-
-
-##################################log parsing functions
-function checkLoaded
-{
- if [[ "$1" =~ .*DALI.*[LOAD].*file\ (.*)\ to\ Bitmap\ (.*)\ -\ size\ ([[:digit:]]*)\ bytes\ (.*) ]]
- then
- local FILENAME="${BASH_REMATCH[1]}"
- local BITMAP="${BASH_REMATCH[2]}"
- local SIZE="${BASH_REMATCH[3]}"
- local SIZE_DETAILS="${BASH_REMATCH[4]}"
-
- local found=0
-
- #check if file was loaded before with same size
- local i=0
- if [ ${#FILENAMES_G[@]} -ne 0 ]
- then
-
- for filenameIter in ${FILENAMES_G[@]}
- do
- if [[ "$filenameIter" == "$FILENAME" ]]
- then
- if [[ ${SIZES_G[$i]} == "$SIZE" && ${SIZE_DETAILS_G[$i]} == "$SIZE_DETAILS" ]]
- then
- found=1
- case ${STATES_G[$i]} in
- 0) #CPU
- BITMAPS_G[$i]="$BITMAP"
- ;;
- 1) #CPUGPU
- BITMAPS_G[$i]="$BITMAP"
- ;;
- 2) #GPU
- STATES_G[$i]=1 #GPU->CPUGPU loaded into memory again
- BITMAPS_G[$i]="$BITMAP"
- ;;
- 3) #DISC
- #previously discarded, load again
- STATES_G[$i]=0
- BITMAPS_G[$i]="$BITMAP"
- ;;
- *)
- error "checkLoaded - unknown state"
- ;;
- esac
- else
- #filename is same, but its loaded in different size
- :
- fi
- fi
- let i+=1
- done
- fi
-
- if [ $found -ne 1 ]
- then
- fileLoaded "$FILENAME" "$BITMAP" "$SIZE" "$SIZE_DETAILS"
- fi
-
- return 0
- else
- error "checkLoaded"
- fi
-}
-
-function checkUploaded
-{
- if [[ "$1" =~ .*DALI.*[UPLOAD].*Bitmap\ (.*)\ to\ Texture\ (.*)\ -\ size\ ([[:digit:]]*)\ bytes\ (.*) ]]
- then
- local BITMAP="${BASH_REMATCH[1]}"
- local TEXTURE="${BASH_REMATCH[2]}"
- local SIZE="${BASH_REMATCH[3]}"
- local SIZE_DETAILS="${BASH_REMATCH[4]}"
-
- local i=0
- local lastIdx=-1
-
- if [[ "$BITMAP" =~ \(nil\) ]]
- then
- atlasUploaded $TEXTURE $SIZE "$SIZE_DETAILS"
- return 0
- else
- #not a texture atlas
- if [ ${#BITMAPS_G[@]} -ne $BITMAP_ID_ATLAS ]
- then
- for bitmap in ${BITMAPS_G[@]}
- do
- if [ $bitmap == $BITMAP ]
- then
- lastIdx=$i
- fi
- let i+=1
- done
- fi
- fi
-
- if [ $lastIdx != -1 ]
- then
- #Bitmap found
- if [[ ${TEXTURES_G[$lastIdx]} == 0 && ${STATES_G[$lastIdx]} == 0 ]]
- then
- #File loaded in memory -> upload to GPU
- TEXTURES_G[$lastIdx]="$TEXTURE"
- STATES_G[$lastIdx]=1
- elif [[ ${FILENAMES_G[$lastIdx]} == "-" && ${STATES_G[$lastIdx]} == 1 ]]
- then
- #BitmapImage already in memory and GPU mem. -> updated
- SIZES_G[$lastIdx]=$SIZE
- SIZE_DETAILS_G[$lastIdx]="$SIZE_DETAILS"
- else
- #bitmap uploaded to new texture
- addRecord ${FILENAMES_G[$lastIdx]} $BITMAP $TEXTURE 1 $SIZE "$SIZE_DETAILS"
- fi
- else
- #bitmapImage - not loaded from file
- #newly added
- addRecord "-" $BITMAP $TEXTURE 1 $SIZE "$SIZE_DETAILS"
- fi
- return 0
- elif [[ "$1" =~ .*DALI.*[UPLOAD].*FrameBufferTexture\ (.*)\ GL\ Texture\ (.*)\ -\ size\ ([[:digit:]]*)\ bytes\ (.*) ]]
- then
- local FBTEXTURE="${BASH_REMATCH[1]}"
- local TEXTURE="${BASH_REMATCH[2]}"
- local SIZE="${BASH_REMATCH[3]}"
- local SIZE_DETAILS="${BASH_REMATCH[4]}"
- frameBufUploaded "$FBTEXTURE" "$TEXTURE" "$SIZE" "$SIZE_DETAILS"
- return 0
- else
- echo "$1"
- error "checkUploaded"
- fi
-}
-
-function checkDeletedBuf
-{
- if [[ "$1" =~ .*DALI.*[DELBUF].*Bitmap\ (.*)\ -\ .*size\ (.*) ]]
- then
- local BITMAP=${BASH_REMATCH[1]}
- local i=0
-
- for bitmap in ${BITMAPS_G[@]}
- do
- if [ $bitmap == "$BITMAP" ]
- then
- case ${STATES_G[$i]} in
- 0)
- STATES_G[$i]=3 #CPU->DISC
- ;;
- 1)
- STATES_G[$i]=2 #CPUGPU->GPU
- ;;
- 2)
- #GPU->?
- #probably previously freed bitmap buffer but memory is reused since
- ;;
- 3)
- #DISC->?
- #probably previously freed but memory is reused since
- ;;
- *)
- error "checkDeletedBuf - unkown state"
- ;;
- esac
- fi
- let i+=1
- done
-
- return 0
- else
- echo "$1"
- error "checkDeletedBuf"
- fi
-}
-
-function checkDeletedTexture
-{
- if [[ "$1" =~ .*DALI.*[DELTEXTURE].*Texture\ (.*)\ -\ size\ (.*) ]]
- then
- local TEXTURE="${BASH_REMATCH[1]}"
- local i=0
- local lastIdx=-1
-
- for texture in ${TEXTURES_G[@]}
- do
- if [ $texture == $TEXTURE ]
- then
- lastIdx=$i
- fi
- let i+=1
- done
-
- if [ $lastIdx != -1 ]
- then
- case ${STATES_G[$lastIdx]} in
- 0)
- #CPU->?
- echo "$1"
- error "checkDeletedTexture - state CPU"
- ;;
- 1)
- STATES_G[$lastIdx]=0 #CPUGPU->CPU
- ;;
- 2)
- STATES_G[$lastIdx]=3 #GPU->DISC
- ;;
- 3)
- #DISC->?
- echo "$1"
- error "checkDeletedTexture - state DISC"
- ;;
- *)
- error "checkDeletedTexture - unkown state"
- ;;
- esac
- else
- echo "$1"
- error "checkDeletedTexture - texture not uploaded"
- fi
- return 0
- else
- echo "$1"
- error "checkDeletedTexture"
- fi
-}
-
-function processLine
-{
- if [[ "$1" =~ .*DALI.*\ \[(.*)\].* ]]
- then
- RESCMD=${BASH_REMATCH[1]}
- case "$RESCMD" in
- LOAD)
- checkLoaded "$1"
- ;;
- UPLOAD)
- checkUploaded "$1"
- ;;
- DELBUF)
- checkDeletedBuf "$1"
- ;;
- DELTEXTURE)
- checkDeletedTexture "$1"
- ;;
- INIT)
- ;;
- FIN)
- return 1 #end of last log session
- ;;
- *)
- error "Unkown command $RESCMD"
- ;;
- esac
- fi
- return 0
-}
-
-function parseFile
-{
- if [ -z "$1" ]
- then
- echo "ERROR in parseFile";
- cleanup; exit 1
- fi
-
- #return if file does not contain dali resource log
- if ! grep -q -m 1 -E "DALI.*\[INIT\]" $1
- then
- return 1
- fi
-
- #find last resource log session
- local LOGBUFFER=$(sed -n 'H; /DALI.*\[INIT\]/h; ${g;p;}' $1)
-
- while read -r line
- do
- #show PID of last process
- PID_G=$(echo "$line" | sed 's/[^0-9]*\([0-9]*\).*/\1/')
- if [ ! -z "$PID_G" ]
- then
- break
- fi
- done <<< "$LOGBUFFER"
-
- while read -r line
- do
- if ! processLine "$line" #stop parsing at the end of last session
- then
- break
- fi
- done <<< "$LOGBUFFER"
-}
-
-##################################draw and main functions
-function redraw
-{
- tput cup 0 0 #move cursor to top left
-
- # print info (4 lines)
- tput bold
- printLine "PID: $PID_G"
- printLine "MEM 3D: $GPUMEM"
- printLine "MEM Atlas: $ATLASMEM";
- printLine "MEM CPU: $CPUMEM"
- printLine "Number of atlases: $ATLAS_NO";
- tput sgr0
-
- # separator bar (colored bar with (actual/number of files) count)
- tput cup $SEPARATOR_H 0
- local PAGEIND="$(expr $CURPAGE + 1)/$(expr $MAXP + 1)"
- local FILL_W=0
- let FILL_W=$TERM_W-${#PAGEIND}
- tput setab 4; printf $PAGEIND%"$FILL_W"s; printf '\n'; tput sgr0
-
- # print filenames
- local count=0
- local index=0
- let index=$CURPAGE*$MAXFILENO
-
- filecount=${#FILENAMES_G[@]}
-
- tput setaf 252
-
- while [[ $count -lt $MAXFILENO ]]
- do
- if [[ $index -lt $filecount ]]
- then
- tput setab ${COLORS[${STATES_G[$index]}]}
-# printPath "${FILENAMES_G[$count]}"
- printLine "${FILENAMES_G[$index]} ${SIZES_G[$index]} ${SIZE_DETAILS_G[$index]}"
- else
- tput sgr0
- printLine "" #clear remaining lines to fill screen
- fi
- let count+=1
- let index+=1
- done
-
- # print keyboard shortcuts
- tput setab 4; tput bold
- IFS= printString " | n: next page | p: previous page | ^C: exit | Resource state: "
- # print color codes
- if [[ $TERM_W -gt 100 ]]
- then
- tput setab ${COLORS[0]}
- echo -n " CPU "
- tput setab ${COLORS[1]}
- echo -n " CPUGPU "
- tput setab ${COLORS[2]}
- echo -n " GPU "
- tput setab ${COLORS[3]}
- echo -n " DISCARDED "
- fi
-
- tput sgr0
-}
-
-function readInput
-{
- local key
- read -n1 -t 0.3 key
-
- case "$key" in
- 'p')
- if [[ $CURPAGE -ne 0 ]]
- then
- let CURPAGE-=1
- fi
- ;;
- 'n')
- if [[ $CURPAGE -lt $MAXP ]]
- then
- let CURPAGE+=1
- fi
- ;;
- esac
-}
-
-function initVars
-{
- FILENAMES_G=( )
- BITMAPS_G=( )
- TEXTURES_G=( )
- SIZES_G=( )
- SIZE_DETAILS_G=( )
- STATES_G=( )
-}
-
-function cleanup
-{
- tput cup 9999 0 #go to bottom of screen
- tput cnorm #show cursor
- tput sgr0
- if [ -f "$DLOGTEMPFILE" ]
- then
- rm "$DLOGTEMPFILE"
- fi
-}
-
-function update
-{
- initVars
- if [ -n "$USING_DLOG" ]
- then
- if [ -f "$DLOGTEMPFILE" ]
- then
- rm "$DLOGTEMPFILE"
- fi
- "$DLOGUTIL" DALI:I -d -f "$DLOGTEMPFILE" 2>/dev/null
- fi
-
- if [ ! -e "$INPUTFILE" ]
- then
- return 1
- fi
-
- parseFile "$INPUTFILE"
-
- if [[ $? -gt 0 || ${#STATES_G[@]} -lt 1 ]]
- then
- return 1
- fi
-
- getCpuMemUsage
- getGpuMemUsage
- getAtlasMemUsage
- getAtlasNumber
-
- getTermSize
- readInput
- redraw
-}
-
-function main
-{
- parseCmdLine $@
-
- if [ -z "$INPUTFILE" ]
- then
- echo No input file specified;
- cleanup
- exit 1
- fi
-
- tput civis #hide cursor
- tput clear #clear screen
-
- echo "waiting for log..."
-
- while [ 1 ]
- do
- update
-# sleep 0.3 # we are now reading input for 0.3
- done
-
- cleanup
-}
-
-trap "cleanup; exit 0" SIGINT SIGTERM #reset terminal when ^C is pressed
-# trap "getTermSize" SIGWINCH #handle window resize
-
-main $@
+++ /dev/null
-Resource log analyzer tool for dali applications
-
-USAGE:
-./dalireslog.sh [FILE]
-if FILE isn't specified script will try to use dlogutil
-
-Example:
-
-sh-4.1$ ./dalireslog.sh
-on a separate terminal:
-sh-4.1$ DALI_ENABLE_LOG=RESOURCE_LOG /opt/apps/com.samsung.dali-demo/bin/album.example
-
-Displayed information:
-3D - amount of GPU memory used by application
-MEM Atlas - amount of GPU memory used by texture atlases. Usually this means font atlases.
-Number of atlases - how many texture atlases are present in memory
-
-A list of files is displayed in the main view, with different color codes representing different states.
-
-CPU - resource is in memory, but hasn't been uploaded to a GL texture
-GPU - resource has been uploaded to a GL texture, bitmap buffer discarded
-CPUGPU - resource has been uploaded to a GL texture, but still present in CPU memory as well
-DISCARDED - resource has been discarded, memory freed up
+++ /dev/null
-#!/usr/bin/env ruby
-# To use type parse.rb in the same folder as gl-abstraction.h
-# and pipe the output to a file
-#
-# Assemble the gl function call
-#
-# turns this: GLBoolean BlendEquation(GLEnum mode);
-#
-# into an inline function like this:
-#
-# GLBoolean BlendEquation(GLEnum mode)
-# {
-# return glBlendEquation(mode);
-# }
-
-f = File.new("x11-gles.h")
-#scan each line in the file
-f.each do |x|
-
- # x is original line, y is the new gl function call
- y = String.new(x)
-
- y.lstrip! # strip leading white spaces
- returns = y.index("void"); # see if the function returns void
- y.gsub!'void',' ' # delete the return types ...
- y.gsub!(/GL[a-z]*/, '') # remove GL types such as GLenum
- y.gsub!('const','') # remove const, *
- y.gsub!('char','') # remove char
- y.gsub!('*','') # remove pointer *
- y.gsub!(/\s+/,"") # remove all spaces
- y.insert(0,' gl') # add gl to function name
-
- if (returns != 0) # insert a return if the function returns
- y.lstrip!
- y.insert(0,' return ')
- end
-
- # print the function out
- y << "\n"
- x.lstrip!
- x.gsub!(';','')
- print x
- print "{\n"
- print y
- print "}\n\n"
-end
-
-
-
--- /dev/null
+# tv profile internal files
+adaptor_common_internal_src_files += \
+ $(adaptor_common_dir)/../tv/tv-key-impl.cpp \
+ $(adaptor_common_dir)/../tv/tv-render-surface-factory.cpp \
+ $(adaptor_common_dir)/../tv/tv-system-settings.cpp \
+ $(adaptor_common_dir)/../tv/tv-color-controller-impl.cpp
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <common/color-controller-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+Dali::ColorController ColorController::Get()
+{
+ Dali::ColorController colorController;
+ return colorController;
+}
+
+ColorController::ColorController()
+{
+}
+
+ColorController::~ColorController()
+{
+}
+
+bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
+{
+ return false;
+}
+
+bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
+{
+ return false;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <key-impl.h>
+
+// EXTERNAL INCLUDES
+#include <utilX.h>
+#include <map>
+#include <string.h>
+#include <iostream>
+
+
+#include <dali/integration-api/debug.h>
+
+
+namespace Dali
+{
+
+const KEY DALI_KEY_INVALID = -1;
+const KEY DALI_KEY_ESCAPE = 9;
+const KEY DALI_KEY_BACK = 166;
+const KEY DALI_KEY_CAMERA = 167;
+const KEY DALI_KEY_CONFIG = 168;
+const KEY DALI_KEY_POWER = 169;
+const KEY DALI_KEY_PAUSE = 170;
+const KEY DALI_KEY_CANCEL = 171;
+const KEY DALI_KEY_PLAY_CD = 172;
+const KEY DALI_KEY_STOP_CD = 173;
+const KEY DALI_KEY_PAUSE_CD = 174;
+const KEY DALI_KEY_NEXT_SONG = 175;
+const KEY DALI_KEY_PREVIOUS_SONG = 176;
+const KEY DALI_KEY_REWIND = 177;
+const KEY DALI_KEY_FASTFORWARD = 178;
+const KEY DALI_KEY_MEDIA = 179;
+const KEY DALI_KEY_PLAY_PAUSE = 180;
+const KEY DALI_KEY_MUTE = 181;
+const KEY DALI_KEY_SEND = 182;
+const KEY DALI_KEY_SELECT = 183;
+const KEY DALI_KEY_END = DALI_KEY_BACK;
+const KEY DALI_KEY_MENU = DALI_KEY_SEND;
+const KEY DALI_KEY_HOME = DALI_KEY_SELECT;
+const KEY DALI_KEY_HOMEPAGE = 187;
+const KEY DALI_KEY_WEBPAGE = 188;
+const KEY DALI_KEY_MAIL = 189;
+const KEY DALI_KEY_SCREENSAVER = 190;
+const KEY DALI_KEY_BRIGHTNESS_UP = 191;
+const KEY DALI_KEY_BRIGHTNESS_DOWN = 192;
+const KEY DALI_KEY_SOFT_KBD = 193;
+const KEY DALI_KEY_QUICK_PANEL = 194;
+const KEY DALI_KEY_TASK_SWITCH = 195;
+const KEY DALI_KEY_APPS = 196;
+const KEY DALI_KEY_SEARCH = 197;
+const KEY DALI_KEY_VOICE = 198;
+const KEY DALI_KEY_LANGUAGE = 199;
+const KEY DALI_KEY_VOLUME_UP = 200;
+const KEY DALI_KEY_VOLUME_DOWN = 201;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace KeyLookup
+{
+
+namespace
+{
+
+struct KeyLookup
+{
+ const char* keyName; ///< X string representation
+ const int daliKeyCode; ///< Dali Enum Representation
+ const bool deviceButton; ///< Whether the key is from a button on the device
+};
+
+// matches a DALI_KEY enum, to a X key name
+KeyLookup KeyLookupTable[]=
+{
+ // more than one key name can be assigned to a single dali-key code
+ // e.g. Menu and KEY_MENU("FS86KeyMenu") are both assigned to DALI_KEY_MENU
+
+ { "Escape", DALI_KEY_ESCAPE, false }, // item not defined in utilX
+ { "Menu", DALI_KEY_MENU, false }, // item not defined in utilX
+// { KEY_CAMERA, DALI_KEY_CAMERA, false },
+// { KEY_CONFIG, DALI_KEY_CONFIG, false },
+ { KEY_POWER, DALI_KEY_POWER, true },
+ { KEY_PAUSE, DALI_KEY_PAUSE, false },
+ { KEY_CANCEL, DALI_KEY_CANCEL, false },
+// { KEY_PLAYCD, DALI_KEY_PLAY_CD, false },
+// { KEY_STOPCD, DALI_KEY_STOP_CD, false },
+// { KEY_PAUSECD, DALI_KEY_PAUSE_CD, false },
+// { KEY_NEXTSONG, DALI_KEY_NEXT_SONG, false },
+// { KEY_PREVIOUSSONG, DALI_KEY_PREVIOUS_SONG, false },
+// { KEY_REWIND, DALI_KEY_REWIND, false },
+// { KEY_FASTFORWARD, DALI_KEY_FASTFORWARD, false },
+// { KEY_MEDIA, DALI_KEY_MEDIA, false },
+// { KEY_PLAYPAUSE, DALI_KEY_PLAY_PAUSE, false },
+ { KEY_MUTE, DALI_KEY_MUTE, false },
+// { KEY_SEND, DALI_KEY_SEND, true },
+// { KEY_SELECT, DALI_KEY_SELECT, true },
+// { KEY_END, DALI_KEY_END, true },
+ { KEY_MENU, DALI_KEY_MENU, true },
+ { KEY_HOME, DALI_KEY_HOME, true },
+ { KEY_BACK, DALI_KEY_BACK, true },
+// { KEY_HOMEPAGE, DALI_KEY_HOMEPAGE, false },
+// { KEY_WEBPAGE, DALI_KEY_WEBPAGE, false },
+// { KEY_MAIL, DALI_KEY_MAIL, false },
+// { KEY_SCREENSAVER, DALI_KEY_SCREENSAVER, false },
+// { KEY_BRIGHTNESSUP, DALI_KEY_BRIGHTNESS_UP, false },
+// { KEY_BRIGHTNESSDOWN, DALI_KEY_BRIGHTNESS_DOWN, false },
+// { KEY_SOFTKBD, DALI_KEY_SOFT_KBD, false },
+// { KEY_QUICKPANEL, DALI_KEY_QUICK_PANEL, false },
+// { KEY_TASKSWITCH, DALI_KEY_TASK_SWITCH, false },
+// { KEY_APPS, DALI_KEY_APPS, false },
+ { KEY_SEARCH, DALI_KEY_SEARCH, false },
+// { KEY_VOICE, DALI_KEY_VOICE, false },
+// { KEY_LANGUAGE, DALI_KEY_LANGUAGE, false },
+ { KEY_VOLUMEUP, DALI_KEY_VOLUME_UP, true },
+ { KEY_VOLUMEDOWN, DALI_KEY_VOLUME_DOWN, true },
+};
+
+const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable))/ (sizeof(KeyLookup));
+
+class KeyMap
+{
+ public:
+
+ KeyMap():
+ mLookup( cmpString )
+ {
+ // create the lookup
+ for( size_t i = 0; i < KEY_LOOKUP_COUNT ; ++i )
+ {
+ const KeyLookup& keyLookup( KeyLookupTable[i] );
+ mLookup[ keyLookup.keyName ] = DaliKeyType( keyLookup.daliKeyCode, keyLookup.deviceButton );
+ }
+ }
+
+ int GetDaliKeyEnum( const char* keyName ) const
+ {
+ Lookup::const_iterator i = mLookup.find( keyName );
+ if( i == mLookup.end() )
+ {
+ return -1;
+ }
+ else
+ {
+ return (*i).second.first;
+ }
+ }
+
+ bool IsDeviceButton( const char* keyName ) const
+ {
+ Lookup::const_iterator i = mLookup.find( keyName );
+ if ( i != mLookup.end() )
+ {
+ return (*i).second.second;
+ }
+ return false;
+ }
+
+ private:
+
+ /**
+ * compare function, to compare string by pointer
+ */
+ static bool cmpString( const char* a, const char* b)
+ {
+ return strcmp(a, b) < 0;
+ }
+
+ typedef std::pair< int, bool > DaliKeyType;
+ typedef std::map<const char* /* key name */, DaliKeyType /* key code */, bool(*) ( char const* a, char const* b) > Lookup;
+ Lookup mLookup;
+
+};
+const KeyMap globalKeyLookup;
+
+} // un-named name space
+
+bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey)
+{
+ int key = globalKeyLookup.GetDaliKeyEnum( keyEvent.keyPressedName.c_str() );
+ return daliKey == key;
+}
+
+bool IsDeviceButton( const char* keyName )
+{
+ return globalKeyLookup.IsDeviceButton( keyName );
+}
+
+} // namespace KeyLookup
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <pixmap-render-surface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECore
+{
+
+DALI_EXPORT_API RenderSurface* CreatePixmapSurface(
+ PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent )
+{
+ return new PixmapRenderSurface( positionSize, surface, display, name, isTransparent );
+}
+
+} // namespace ECoreX
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+
+
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <system_settings.h>
+#include <Elementary.h>
+
+// INTERNAL INCLUDES
+#include <system-settings.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+int GetLongPressTime( int defaultTime )
+{
+ return defaultTime;
+}
+
+int GetElmAccessActionOver()
+{
+ return ELM_ACCESS_ACTION_OVER;
+}
+
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "accessibility-manager-impl.h"
+
+// EXTERNAL INCLUDES
+#include <vconf.h>
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+#include <Elementary.h>
+
+#include <dali/public-api/dali-core.h>
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/gesture-requests.h>
+#include "system-settings.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+bool AccessibilityManager::HandleActionNextEvent(bool allowEndFeedback)
+{
+ bool ret = false;
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionNext signal in first, AccessibilityActionNext for handler in next
+ */
+ if( !mIndicatorFocused )
+ {
+ if( !mActionNextSignalV2.Empty() )
+ {
+ mActionNextSignalV2.Emit( handle );
+ }
+ }
+
+ if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionPreviousEvent(bool allowEndFeedback)
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionPrevious signal in first, AccessibilityActionPrevious for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionPreviousSignalV2.Empty() )
+ {
+ mActionPreviousSignalV2.Emit( handle );
+ }
+ }
+
+ if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionActivateEvent()
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionActivate signal in first, AccessibilityActionActivate for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionActivateSignalV2.Empty() )
+ {
+ mActionActivateSignalV2.Emit( handle );
+ }
+ }
+
+ if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionActivate();
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
+{
+ bool ret = false;
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
+
+ mReadPosition.x = x;
+ mReadPosition.y = y;
+
+ Dali::AccessibilityManager handle( this );
+
+ bool indicatorFocused = false;
+
+ // Check whether the Indicator is focused
+ if( mIndicator && mIndicator->IsConnected() )
+ {
+ // Check the position and size of Indicator actor
+ Dali::Actor indicatorActor = mIndicator->GetActor();
+ Vector3 position = Vector3(0.0f, 0.0f, 0.0f);
+ Vector3 size = indicatorActor.GetCurrentSize();
+
+ if(mReadPosition.x >= position.x &&
+ mReadPosition.x <= position.x + size.width &&
+ mReadPosition.y >= position.y &&
+ mReadPosition.y <= position.y + size.height)
+ {
+ indicatorFocused = true;
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Indicator area!!!!\n", __FUNCTION__, __LINE__);
+ }
+ }
+
+ if( mIndicator )
+ {
+ if( !mIndicatorFocused && indicatorFocused )
+ {
+ // If Indicator is focused, the focus should be cleared in Dali focus chain.
+ if( mActionHandler )
+ {
+ mActionHandler->ClearAccessibilityFocus();
+ }
+ }
+ else if( mIndicatorFocused && !indicatorFocused )
+ {
+ }
+
+ mIndicatorFocused = indicatorFocused;
+
+ // Send accessibility READ action information to Indicator
+ if( mIndicatorFocused )
+ {
+ }
+ }
+
+ if(allowReadAgain)
+ {
+ /*
+ * In order to application decide reading action first,
+ * emit ActionRead signal in first, AccessibilityActionRead for handler in next
+ */
+ if( !mIndicatorFocused )
+ {
+ if ( !mActionReadSignalV2.Empty() )
+ {
+ mActionReadSignalV2.Emit( handle );
+ }
+ }
+ }
+ else
+ {
+ /*
+ * In order to application decide reading action first,
+ * emit ActionRead signal in first, AccessibilityActionRead for handler in next
+ */
+ if( !mIndicatorFocused )
+ {
+ if ( !mActionOverSignalV2.Empty() )
+ {
+ mActionOverSignalV2.Emit( handle );
+ }
+ }
+ }
+
+ if( mActionHandler && !mIndicatorFocused)
+ {
+ // If Indicator is not focused, the accessibility actions should be handled by the registered
+ // accessibility action handler (e.g. focus manager)
+ ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+ }
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionReadNextEvent(bool allowEndFeedback)
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionReadNext signal in first, AccessibilityActionReadNext for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionReadNextSignalV2.Empty() )
+ {
+ mActionReadNextSignalV2.Emit( handle );
+ }
+ }
+
+ if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionReadPreviousEvent(bool allowEndFeedback)
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionReadPrevious signal in first, AccessibilityActionReadPrevious for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionReadPreviousSignalV2.Empty() )
+ {
+ mActionReadPreviousSignalV2.Emit( handle );
+ }
+ }
+
+ if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionUpEvent()
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionUp signal in first, AccessibilityActionUp for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionUpSignalV2.Empty() )
+ {
+ mActionUpSignalV2.Emit( handle );
+ }
+ }
+
+ if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionUp();
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionDownEvent()
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionDown signal in first, AccessibilityActionDown for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionDownSignalV2.Empty() )
+ {
+ mActionDownSignalV2.Emit( handle );
+ }
+ }
+
+ if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionDown();
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "clipboard-impl.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <adaptor.h>
+#include <dali/public-api/object/any.h>
+#include <adaptor-impl.h>
+
+namespace //unnamed namespace
+{
+const char* const CBHM_WINDOW = "CBHM_XWIN";
+const char* const CBHM_MSG = "CBHM_MSG";
+const char* const CBHM_ITEM = "CBHM_ITEM";
+const char* const CBHM_cCOUNT = "CBHM_cCOUNT";
+const char* const CBHM_ERROR = "CBHM_ERROR";
+const char* const SET_ITEM = "SET_ITEM";
+const char* const SHOW = "show0";
+const char* const HIDE = "cbhm_hide";
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Clipboard
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+BaseHandle Create()
+{
+ BaseHandle handle( Clipboard::Get() );
+
+ return handle;
+}
+TypeRegistration CLIPBOARD_TYPE( typeid(Dali::Clipboard), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
+
+} // unnamed namespace
+
+Clipboard::~Clipboard()
+{
+}
+
+Dali::Clipboard Clipboard::Get()
+{
+ Dali::Clipboard clipboard;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::Clipboard ) );
+ if(handle)
+ {
+ // If so, downcast the handle
+ clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
+ }
+ }
+
+ return clipboard;
+}
+bool Clipboard::SetItem(const std::string &itemData )
+{
+ return true;
+}
+
+/*
+ * Get string at given index of clipboard
+ */
+std::string Clipboard::GetItem( unsigned int index ) // change string to a Dali::Text object.
+{
+ if ( index >= NumberOfItems() )
+ {
+ return "";
+ }
+
+ std::string emptyString( "" );
+ char sendBuf[20];
+
+ snprintf( sendBuf, 20, "%s%d", CBHM_ITEM, index );
+ return emptyString;
+}
+
+/*
+ * Get number of items in clipboard
+ */
+unsigned int Clipboard::NumberOfItems()
+{
+ int count = -1;
+
+ return count;
+}
+
+/**
+ * Show clipboard window
+ * Function to send message to show the Clipboard (cbhm) as no direct API available
+ * Reference elementary/src/modules/ctxpopup_copypasteUI/cbhm_helper.c
+ */
+void Clipboard::ShowClipboard()
+{
+}
+
+void Clipboard::HideClipboard()
+{
+}
+
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_CLIPBOARD_H__
+#define __DALI_INTERNAL_CLIPBOARD_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <clipboard.h>
+#include <dali/public-api/object/base-object.h>
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Implementation of the Clip Board
+ */
+
+class Clipboard : public Dali::BaseObject
+{
+public:
+
+ /**
+ * @copydoc Dali::ClipboardEventNotifier::Get()
+ */
+ static Dali::Clipboard Get();
+
+ virtual ~Clipboard();
+
+ /**
+ * @copydoc Dali::Clipboard::SetItem()
+ */
+ bool SetItem(const std::string &itemData);
+
+ /**
+ * @copydoc Dali::Clipboard::GetItem()
+ */
+ std::string GetItem( unsigned int index );
+
+ /**
+ * @copydoc Dali::Clipboard::NumberOfClipboardItems()
+ */
+ unsigned int NumberOfItems();
+
+ /**
+ * @copydoc Dali::Clipboard::ShowClipboard()
+ */
+ void ShowClipboard();
+
+ /**
+ * @copydoc Dali::Clipboard::HideClipboard()
+ */
+ void HideClipboard();
+
+
+private:
+ Clipboard( const Clipboard& );
+ Clipboard& operator=( Clipboard& );
+
+}; // class clipboard
+
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+ inline static Internal::Adaptor::Clipboard& GetImplementation(Dali::Clipboard& clipboard)
+ {
+ DALI_ASSERT_ALWAYS( clipboard && "Clipboard handle is empty" );
+ BaseObject& handle = clipboard.GetBaseObject();
+ return static_cast<Internal::Adaptor::Clipboard&>(handle);
+ }
+
+ inline static const Internal::Adaptor::Clipboard& GetImplementation(const Dali::Clipboard& clipboard)
+ {
+ DALI_ASSERT_ALWAYS( clipboard && "Clipboard handle is empty" );
+ const BaseObject& handle = clipboard.GetBaseObject();
+ return static_cast<const Internal::Adaptor::Clipboard&>(handle);
+ }
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_CLIPBOARD_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <ecore-wl-render-surface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECore
+{
+
+DALI_EXPORT_API RenderSurface* CreatePixmapSurface(
+ PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent )
+{
+ return NULL;
+}
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+
+
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_ECORE_WL_RENDER_SURFACE_FACTORY_H__
+#define __DALI_INTERNAL_ADAPTOR_ECORE_WL_RENDER_SURFACE_FACTORY_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/any.hpp>
+#include <string>
+#include <dali/public-api/math/rect.h>
+#include <dali/public-api/common/dali-common.h>
+
+// INTERNAL INCLUDES
+#include <native-buffer-pool.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECore
+{
+
+class RenderSurface;
+
+/**
+ * Surface factory function for pixmap
+ * A pixmap surface is created.
+ *
+ * @param [in] type the type of surface to create
+ * @param [in] positionSize the position and size of the surface to create
+ * @param [in] display Wayland Pixmap to use, or null for default.
+ * @param [in] display Wayland Display to use, or null for default.
+ * @param [in] name Name of surface passed in
+ * @param [in] isTransparent Whether the surface has an alpha channel
+ */
+DALI_IMPORT_API RenderSurface* CreatePixmapSurface(
+ PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent );
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ADAPTOR_ECORE_X_RENDER_SURFACE_FACTORY_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "ecore-wl-render-surface.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/gl-abstraction.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <ecore-wl-types.h>
+#include <trigger-event.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_ECORE_X_RENDER_SURFACE");
+#endif
+
+namespace ECore
+{
+
+namespace
+{
+
+const float MINIMUM_DIMENSION_CHANGE = 1.0f; ///< Minimum change for window to be considered to have moved
+static bool gWlInitThreadsCalled = false; ///< global to say whether WlInitThreads has been called in this process
+const unsigned int MICROSECONDS_PER_SECOND = 1000000;
+const unsigned int MILLISECONDS_PER_SECOND = 1000;
+
+} // unnamed namespace
+
+RenderSurface::RenderSurface( SurfaceType type,
+ Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent)
+: mMainDisplay(NULL),
+ mType(type),
+ mPosition(positionSize),
+ mTitle(name),
+ mColorDepth(isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24),
+ mRenderMode((type == PIXMAP) ? RENDER_SYNC : RENDER_DEFAULT),
+ mRenderNotification( NULL ),
+ mSyncReceived( false ),
+ mOwnSurface(false),
+ mOwnDisplay(false),
+ mIsStopped( false )
+{
+ // see if there is a display in Any display
+ SetDisplay( display );
+}
+
+void RenderSurface::Init( Any surface )
+{
+ // see if there is a surface in Any surface
+ unsigned int surfaceId = GetSurfaceId( surface );
+
+ // if the surface is empty, create a new one.
+ if ( surfaceId == 0 )
+ {
+ if ( !gWlInitThreadsCalled )
+ {
+ ecore_wl_init(NULL);
+ mMainDisplay = ecore_wl_display_get();
+ mOwnDisplay = true;
+ gWlInitThreadsCalled = true;
+ }
+
+ // we own the surface about to created
+ mOwnSurface = true;
+ CreateWlRenderable();
+ }
+ else
+ {
+ // XLib should already be initialized so no point in calling XInitThreads
+ UseExistingRenderable( surfaceId );
+ }
+
+#ifdef DEBUG_ENABLED
+ // prints out 'INFO: DALI: new RenderSurface, created display xx, used existing surface xx
+ // we can not use LOG_INFO because the surface can be created before Dali Core is created.
+ printf( "INFO: DALI: new RenderSurface, %s display %p, %s %s surface %X \n",
+ mOwnDisplay?"created":"used existing",mMainDisplay,
+ mOwnSurface?"created":"used existing",
+ Dali::RenderSurface::PIXMAP==mType?" pixmap" :"window",
+ GetDrawable() );
+#endif
+}
+
+RenderSurface::~RenderSurface()
+{
+ // release the display connection if we use our own
+ if( mOwnDisplay )
+ {
+ if( mMainDisplay )
+ {
+ // NOTE, on 64bit desktop with some NVidia driver versions this crashes
+ }
+ }
+}
+
+Ecore_Wl_Window* RenderSurface::GetWlWindow()
+{
+ return 0;
+}
+
+WlDisplay* RenderSurface::GetMainDisplay()
+{
+ return mMainDisplay;
+}
+
+void RenderSurface::SetRenderNotification( TriggerEvent* renderNotification )
+{
+ mRenderNotification = renderNotification;
+}
+
+Ecore_Wl_Window* RenderSurface::GetDrawable()
+{
+ return 0;
+}
+
+Any RenderSurface::GetDisplay()
+{
+ // this getter is used by main thread so we need to return the main thread version of the display
+ return Any( ecore_wl_display_get() );
+}
+
+PositionSize RenderSurface::GetPositionSize() const
+{
+ return mPosition;
+}
+
+void RenderSurface::SetRenderMode(RenderMode mode)
+{
+ mRenderMode = mode;
+}
+
+Dali::RenderSurface::RenderMode RenderSurface::GetRenderMode() const
+{
+ return mRenderMode;
+}
+
+void RenderSurface::MoveResize( Dali::PositionSize positionSize )
+{
+ // nothing to do in base class
+}
+
+void RenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) const
+{
+ // calculate DPI
+ float xres, yres;
+
+ // 1 inch = 25.4 millimeters
+ xres = ecore_wl_dpi_get();
+ yres = ecore_wl_dpi_get();
+
+ dpiHorizontal = int(xres + 0.5f); // rounding
+ dpiVertical = int(yres + 0.5f);
+}
+
+void RenderSurface::Map()
+{
+}
+
+void RenderSurface::TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface )
+{
+ // if we don't own the display return
+ if( mOwnDisplay == false )
+ {
+ return;
+ }
+
+ RenderSurface* other = dynamic_cast< RenderSurface* >( &newSurface );
+ if( other )
+ {
+ // if both surfaces share the same display, and this surface owns it,
+ // then transfer the ownership to the new surface
+ if( other->mMainDisplay == mMainDisplay )
+ {
+ mOwnDisplay = false;
+ other->mOwnDisplay = true;
+ }
+ }
+}
+
+void RenderSurface::ConsumeEvents()
+{
+}
+
+void RenderSurface::StopRender()
+{
+ // Stop blocking waiting for sync
+ SetSyncMode( RenderSurface::SYNC_MODE_NONE );
+ // Simulate a RenderSync in case render-thread is currently blocked
+ RenderSync();
+
+ mIsStopped = true;
+}
+
+void RenderSurface::SetViewMode( ViewMode )
+{
+}
+
+void RenderSurface::SetDisplay( Any display )
+{
+ // the render surface can be passed either EFL e-core types, or x11 types
+ // we use boost any to determine at run time which type
+
+ if ( display.Empty() == false )
+ {
+ // check we have a valid type
+ DALI_ASSERT_ALWAYS( ( ( display.GetType() == typeid (Ecore_Wl_Display *)) ||
+ ( display.GetType() == typeid (WlDisplay *) ) )
+ &&
+ "Display type is invalid" );
+
+ mOwnDisplay = false;
+
+ // display may point to EcoreXDisplay so may need to cast
+ if( display.GetType() == typeid (Ecore_Wl_Display*) )
+ {
+ mMainDisplay = static_cast< WlDisplay* >( ecore_wl_display_get() );
+ }
+ else
+ {
+ mMainDisplay = AnyCast< WlDisplay* >( display );
+ }
+ }
+}
+
+unsigned int RenderSurface::GetSurfaceId( Any surface ) const
+{
+ unsigned int surfaceId = 0;
+
+ if ( surface.Empty() == false )
+ {
+ // check we have a valid type
+ DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (Ecore_Wl_Window *) ) )
+ && "Surface type is invalid" );
+
+ surfaceId = AnyCast<unsigned int>( surface );
+ }
+ return surfaceId;
+}
+
+void RenderSurface::RenderSync()
+{
+ // nothing to do
+}
+
+void RenderSurface::DoRenderSync( unsigned int timeDelta, SyncMode syncMode )
+{
+ // Should block waiting for RenderSync?
+ if( mRenderMode == Dali::RenderSurface::RENDER_SYNC )
+ {
+ boost::unique_lock< boost::mutex > lock( mSyncMutex );
+
+ // wait for sync
+ if( syncMode != SYNC_MODE_NONE &&
+ mSyncMode != SYNC_MODE_NONE &&
+ !mSyncReceived )
+ {
+ mSyncNotify.wait( lock );
+ }
+ mSyncReceived = false;
+ }
+ // Software sync based on a timed delay?
+ else if( mRenderMode > Dali::RenderSurface::RENDER_SYNC )
+ {
+ unsigned int syncPeriod( MICROSECONDS_PER_SECOND / static_cast< unsigned int >( mRenderMode ) - MILLISECONDS_PER_SECOND );
+ if( timeDelta < syncPeriod )
+ {
+ usleep( syncPeriod - timeDelta );
+ }
+ }
+}
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ECORE_WL_RENDER_SURFACE_H__
+#define __DALI_INTERNAL_ECORE_WL_RENDER_SURFACE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <boost/thread.hpp>
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+#include <dali/public-api/common/dali-common.h>
+
+// INTERNAL INCLUDES
+#include <render-surface-impl.h>
+#include <ecore-wl-types.h>
+#include <gl/egl-implementation.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class TriggerEvent;
+
+namespace ECore
+{
+
+/**
+ * Ecore Wayland implementation of render surface.
+ * @todo change namespace to ECore_Wayland as the class
+ * is no longer pure Wayland.
+ */
+class DALI_IMPORT_API RenderSurface : public Internal::Adaptor::RenderSurface
+{
+public:
+ /**
+ * Uses an Wayland surface to render to.
+ * @param [in] type the type of surface passed in
+ * @param [in] positionSize the position and size of the surface
+ * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
+ * @param [in] display connection to X-server if the surface is a X window or pixmap (type must be void * to X display struct)
+ * @param [in] name optional name of surface passed in
+ * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
+ */
+ RenderSurface( SurfaceType type,
+ Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent = false);
+
+ /**
+ * Destructor.
+ * Will delete the display, if it has ownership.
+ * Will delete the window/pixmap if it has owner ship
+ */
+ virtual ~RenderSurface();
+
+protected:
+ /**
+ * Second stage construction
+ * Creates the surface (window, pixmap or native buffer)
+ */
+ void Init( Any surface );
+
+public: // API
+
+ /**
+ * @return the Ecore X window handle
+ */
+ Ecore_Wl_Window* GetWlWindow();
+
+ /**
+ * @return the Main X display
+ */
+ WlDisplay* GetMainDisplay();
+
+ /**
+ * Sets the render notification trigger to call when render thread is completed a frame
+ * @param renderNotification to use
+ */
+ void SetRenderNotification( TriggerEvent* renderNotification );
+
+ /**
+ * Get the surface as an Ecore_X_drawable
+ */
+ virtual Ecore_Wl_Window* GetDrawable();
+
+public: // from Dali::RenderSurface
+
+ /**
+ * @copydoc Dali::RenderSurface::GetType()
+ */
+ virtual Dali::RenderSurface::SurfaceType GetType() = 0;
+
+ /**
+ * @copydoc Dali::RenderSurface::GetSurface()
+ */
+ virtual Any GetSurface() = 0;
+
+ /**
+ * @copydoc Dali::RenderSurface::GetDisplay()
+ */
+ virtual Any GetDisplay();
+
+ /**
+ * @copydoc Dali::RenderSurface::GetPositionSize()
+ */
+ virtual PositionSize GetPositionSize() const;
+
+ /**
+ * @copydoc Dali::RenderSurface::SetRenderMode()
+ */
+ virtual void SetRenderMode(RenderMode mode);
+
+ /**
+ * @copydoc Dali::RenderSurface::GetRenderMode()
+ */
+ virtual RenderMode GetRenderMode() const;
+
+public: // from Internal::Adaptor::RenderSurface
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface()
+ */
+ virtual void CreateEglSurface( EglInterface& egl ) = 0;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface()
+ */
+ virtual void DestroyEglSurface( EglInterface& egl ) = 0;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface()
+ */
+ virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::MoveResize()
+ */
+ virtual void MoveResize( Dali::PositionSize positionSize);
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::GetDpi()
+ */
+ virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) const;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::Map()
+ */
+ virtual void Map();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::TransferDisplayOwner()
+ */
+ virtual void TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::ConsumeEvents()
+ */
+ virtual void ConsumeEvents();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::RenderSync()
+ */
+ virtual void RenderSync();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::SetViewMode()
+ */
+ void SetViewMode( ViewMode );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::PreRender()
+ */
+ virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) = 0;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::PostRender()
+ */
+ virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode ) = 0;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::StopRender()
+ */
+ virtual void StopRender();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::SetSyncMode()
+ */
+ virtual void SetSyncMode( SyncMode syncMode ) { mSyncMode = syncMode; }
+
+private:
+
+ /**
+ * Sets the display, if display parameter is empty it opens a new display
+ * @param display
+ */
+ void SetDisplay( Any display );
+
+ /**
+ * Get the surface id if the surface parameter is not empty
+ * @param surface Any containing a surface id, or can be empty
+ * @return surface id, or zero if surface is empty
+ */
+ unsigned int GetSurfaceId( Any surface ) const;
+
+protected:
+
+ /**
+ * Create XRenderable
+ */
+ virtual void CreateWlRenderable() = 0;
+
+ /**
+ * Use an existing render surface
+ * @param surfaceId the id of the surface
+ */
+ virtual void UseExistingRenderable( unsigned int surfaceId ) = 0;
+
+ /**
+ * Perform render sync
+ * @param[in] currentTime Current time in microseconds
+ * @param[in] syncMode Wait for RenderSync (from Adaptor) flag. A member of SyncMode
+ */
+ void DoRenderSync( unsigned int timeDelta, SyncMode syncMode );
+
+protected: // Data
+
+ WlDisplay* mMainDisplay; ///< Wayland-connection for rendering
+ SurfaceType mType; ///< type of renderable
+ PositionSize mPosition; ///< Position
+ std::string mTitle; ///< Title of window which shows from "xinfo -topvwins" command
+ ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
+ RenderMode mRenderMode; ///< Render mode for pixmap surface type
+ TriggerEvent* mRenderNotification; ///< Render notificatin trigger
+ boost::mutex mSyncMutex; ///< mutex to lock during waiting sync
+ boost::condition_variable mSyncNotify; ///< condition to notify main thread that pixmap was flushed to onscreen
+ SyncMode mSyncMode;
+ bool mSyncReceived; ///< true, when a pixmap sync has occurred, (cleared after reading)
+ bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
+ bool mOwnDisplay; ///< Whether we own the display (responsible for deleting it)
+ bool mIsStopped; ///< Render should be stopped
+};
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ECORE_WL_RENDER_SURFACE_H__
--- /dev/null
+#ifndef __DALI_INTERNAL_X11_TYPES_H__
+#define __DALI_INTERNAL_X11_TYPES_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <wayland-client.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+typedef ::wl_display WlDisplay;
+typedef ::wl_surface WlSurface;
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif /* __DALI_INTERNAL_X11_TYPES_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+// CLASS HEADER
+#include <gl/egl-implementation.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/dali-vector.h>
+
+// INTERNAL INCLUDES
+#include <ecore-wl-render-surface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+#define TEST_EGL_ERROR(lastCommand) \
+{ \
+ EGLint err = eglGetError(); \
+ if (err != EGL_SUCCESS) \
+ { \
+ DALI_LOG_ERROR("EGL error after %s code=%d\n", lastCommand,err); \
+ DALI_ASSERT_ALWAYS(0 && "EGL error"); \
+ } \
+}
+
+EglImplementation::EglImplementation()
+ : mEglNativeDisplay(0),
+ mEglNativeWindow(0),
+ mEglNativePixmap(0),
+ mEglDisplay(0),
+ mEglConfig(0),
+ mEglContext(0),
+ mEglSurface(0),
+ mGlesInitialized(false),
+ mIsOwnSurface(true),
+ mSyncMode(FULL_SYNC),
+ mContextCurrent(false),
+ mIsWindow(true),
+ mColorDepth(COLOR_DEPTH_24)
+{
+}
+
+EglImplementation::~EglImplementation()
+{
+ TerminateGles();
+}
+
+bool EglImplementation::InitializeGles( EGLNativeDisplayType display, bool isOwnSurface )
+{
+ if ( !mGlesInitialized )
+ {
+ mEglNativeDisplay = display;
+
+ //@todo see if we can just EGL_DEFAULT_DISPLAY instead
+ mEglDisplay = eglGetDisplay(mEglNativeDisplay);
+
+ EGLint majorVersion = 0;
+ EGLint minorVersion = 0;
+ if ( !eglInitialize( mEglDisplay, &majorVersion, &minorVersion ) )
+ {
+ return false;
+ }
+ eglBindAPI(EGL_OPENGL_ES_API);
+
+ mContextAttribs.Clear();
+
+#if DALI_GLES_VERSION >= 30
+
+ mContextAttribs.Reserve(5);
+ mContextAttribs.PushBack( EGL_CONTEXT_MAJOR_VERSION_KHR );
+ mContextAttribs.PushBack( 3 );
+ mContextAttribs.PushBack( EGL_CONTEXT_MINOR_VERSION_KHR );
+ mContextAttribs.PushBack( 0 );
+
+#else // DALI_GLES_VERSION >= 30
+
+ mContextAttribs.Reserve(3);
+ mContextAttribs.PushBack( EGL_CONTEXT_CLIENT_VERSION );
+ mContextAttribs.PushBack( 2 );
+
+#endif // DALI_GLES_VERSION >= 30
+
+ mContextAttribs.PushBack( EGL_NONE );
+
+ mGlesInitialized = true;
+ mIsOwnSurface = isOwnSurface;
+ }
+
+ return mGlesInitialized;
+}
+
+bool EglImplementation::CreateContext()
+{
+ // make sure a context isn't created twice
+ DALI_ASSERT_ALWAYS( (mEglContext == 0) && "EGL context recreated" );
+
+ mEglContext = eglCreateContext(mEglDisplay, mEglConfig, NULL, &(mContextAttribs[0]));
+ TEST_EGL_ERROR("eglCreateContext render thread");
+
+ DALI_ASSERT_ALWAYS( EGL_NO_CONTEXT != mEglContext && "EGL context not created" );
+
+ return true;
+}
+
+void EglImplementation::DestroyContext()
+{
+ DALI_ASSERT_ALWAYS( mEglContext && "no EGL context" );
+
+ eglDestroyContext( mEglDisplay, mEglContext );
+ mEglContext = 0;
+}
+
+void EglImplementation::DestroySurface()
+{
+ if(mIsOwnSurface && mEglSurface)
+ {
+ eglDestroySurface( mEglDisplay, mEglSurface );
+ mEglSurface = 0;
+ }
+}
+
+void EglImplementation::MakeContextCurrent()
+{
+ mContextCurrent = true;
+
+ if(mIsOwnSurface)
+ {
+ eglMakeCurrent( mEglDisplay, mEglSurface, mEglSurface, mEglContext );
+ }
+
+ EGLint error = eglGetError();
+
+ if ( error != EGL_SUCCESS )
+ {
+ switch (error)
+ {
+ case EGL_BAD_DISPLAY:
+ {
+ DALI_LOG_ERROR("EGL_BAD_DISPLAY : Display is not an EGL display connection");
+ break;
+ }
+ case EGL_NOT_INITIALIZED:
+ {
+ DALI_LOG_ERROR("EGL_NOT_INITIALIZED : Display has not been initialized");
+ break;
+ }
+ case EGL_BAD_SURFACE:
+ {
+ DALI_LOG_ERROR("EGL_BAD_SURFACE : Draw or read is not an EGL surface");
+ break;
+ }
+ case EGL_BAD_CONTEXT:
+ {
+ DALI_LOG_ERROR("EGL_BAD_CONTEXT : Context is not an EGL rendering context");
+ break;
+ }
+ case EGL_BAD_MATCH:
+ {
+ DALI_LOG_ERROR("EGL_BAD_MATCH : Draw or read are not compatible with context, or if context is set to EGL_NO_CONTEXT and draw or read are not set to EGL_NO_SURFACE, or if draw or read are set to EGL_NO_SURFACE and context is not set to EGL_NO_CONTEXT");
+ break;
+ }
+ case EGL_BAD_ACCESS:
+ {
+ DALI_LOG_ERROR("EGL_BAD_ACCESS : Context is current to some other thread");
+ break;
+ }
+ case EGL_BAD_NATIVE_PIXMAP:
+ {
+ DALI_LOG_ERROR("EGL_BAD_NATIVE_PIXMAP : A native pixmap underlying either draw or read is no longer valid.");
+ break;
+ }
+ case EGL_BAD_NATIVE_WINDOW:
+ {
+ DALI_LOG_ERROR("EGL_BAD_NATIVE_WINDOW : A native window underlying either draw or read is no longer valid.");
+ break;
+ }
+ case EGL_BAD_CURRENT_SURFACE:
+ {
+ DALI_LOG_ERROR("EGL_BAD_CURRENT_SURFACE : The previous context has unflushed commands and the previous surface is no longer valid.");
+ break;
+ }
+ case EGL_BAD_ALLOC:
+ {
+ DALI_LOG_ERROR("EGL_BAD_ALLOC : Allocation of ancillary buffers for draw or read were delayed until eglMakeCurrent is called, and there are not enough resources to allocate them");
+ break;
+ }
+ case EGL_CONTEXT_LOST:
+ {
+ DALI_LOG_ERROR("EGL_CONTEXT_LOST : If a power management event has occurred. The application must destroy all contexts and reinitialise OpenGL ES state and objects to continue rendering");
+ break;
+ }
+ default:
+ {
+ DALI_LOG_ERROR("Unknown error");
+ break;
+ }
+ }
+ DALI_ASSERT_ALWAYS(false && "MakeContextCurrent failed!");
+ }
+
+ // We want to display this information all the time, so use the LogMessage directly
+ Integration::Log::LogMessage(Integration::Log::DebugInfo, "EGL Information\n"
+ " Vendor: %s\n"
+ " Version: %s\n"
+ " Client APIs: %s\n"
+ " Extensions: %s\n",
+ eglQueryString(mEglDisplay, EGL_VENDOR),
+ eglQueryString(mEglDisplay, EGL_VERSION),
+ eglQueryString(mEglDisplay, EGL_CLIENT_APIS),
+ eglQueryString(mEglDisplay, EGL_EXTENSIONS));
+
+ if ( mIsWindow )
+ {
+ SetRefreshSync( mSyncMode );
+ }
+}
+
+void EglImplementation::MakeContextNull()
+{
+ mContextCurrent = false;
+ // clear the current context
+ eglMakeCurrent( mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
+}
+
+void EglImplementation::TerminateGles()
+{
+ if ( mGlesInitialized )
+ {
+ // in latest Mali DDK (r2p3 ~ r3p0 in April, 2012),
+ // MakeContextNull should be called before eglDestroy surface
+ // to prevent crash in _mali_surface_destroy_callback
+ MakeContextNull();
+
+ if(mIsOwnSurface && mEglSurface)
+ {
+ eglDestroySurface(mEglDisplay, mEglSurface);
+ }
+ eglDestroyContext(mEglDisplay, mEglContext);
+
+ eglTerminate(mEglDisplay);
+
+ mEglDisplay = NULL;
+ mEglConfig = NULL;
+ mEglContext = NULL;
+ mEglSurface = NULL;
+
+ mGlesInitialized = false;
+ }
+}
+
+bool EglImplementation::IsGlesInitialized() const
+{
+ return mGlesInitialized;
+}
+
+bool EglImplementation::SetRefreshSync( SyncMode mode )
+{
+ if ( mIsWindow == false )
+ {
+ return false;
+ }
+ mSyncMode = mode;
+
+ // eglSwapInterval specifies the minimum number of video frame periods
+ // per buffer swap for the window associated with the current context.
+
+ if ( !mContextCurrent )
+ {
+ return true;
+ }
+
+ EGLBoolean ok = eglSwapInterval( mEglDisplay, mode );
+ if ( !ok )
+ {
+ TEST_EGL_ERROR("eglSwapInterval");
+ return false;
+ }
+
+ return true;
+}
+
+void EglImplementation::SwapBuffers()
+{
+ eglSwapBuffers( mEglDisplay, mEglSurface );
+}
+
+void EglImplementation::CopyBuffers()
+{
+ eglCopyBuffers( mEglDisplay, mEglSurface, mEglNativePixmap );
+}
+
+void EglImplementation::WaitGL()
+{
+ eglWaitGL();
+}
+
+void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
+{
+ if(mEglConfig && isWindowType == mIsWindow && mColorDepth == depth)
+ {
+ return;
+ }
+
+ mIsWindow = isWindowType;
+
+ EGLint numConfigs;
+ Vector<EGLint> configAttribs;
+ configAttribs.Reserve(31);
+
+ if(isWindowType)
+ {
+ configAttribs.PushBack( EGL_SURFACE_TYPE );
+ configAttribs.PushBack( EGL_WINDOW_BIT );
+ }
+ else
+ {
+ configAttribs.PushBack( EGL_SURFACE_TYPE );
+ configAttribs.PushBack( EGL_PIXMAP_BIT );
+ }
+
+ configAttribs.PushBack( EGL_RENDERABLE_TYPE );
+
+#if DALI_GLES_VERSION >= 30
+
+#ifdef _ARCH_ARM_
+ configAttribs.PushBack( EGL_OPENGL_ES3_BIT_KHR );
+#else
+ // There is a bug in the desktop emulator
+ // Requesting for ES3 causes eglCreateContext even though it allows to ask
+ // for a configuration that supports GLES 3.0
+ configAttribs.PushBack( EGL_OPENGL_ES2_BIT );
+#endif // _ARCH_ARM_
+
+#else // DALI_GLES_VERSION >= 30
+
+ configAttribs.PushBack( EGL_OPENGL_ES2_BIT );
+
+#endif //DALI_GLES_VERSION >= 30
+
+#if DALI_GLES_VERSION >= 30
+// TODO: enable this flag when it becomes supported
+// configAttribs.PushBack( EGL_CONTEXT_FLAGS_KHR );
+// configAttribs.PushBack( EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR );
+#endif //DALI_GLES_VERSION >= 30
+
+ configAttribs.PushBack( EGL_RED_SIZE );
+ configAttribs.PushBack( 8 );
+ configAttribs.PushBack( EGL_GREEN_SIZE );
+ configAttribs.PushBack( 8 );
+ configAttribs.PushBack( EGL_BLUE_SIZE );
+ configAttribs.PushBack( 8 );
+
+ configAttribs.PushBack( EGL_ALPHA_SIZE );
+#ifdef _ARCH_ARM_
+ configAttribs.PushBack( (depth == COLOR_DEPTH_32) ? 8 : 0 );
+#else
+ // There is a bug in the desktop emulator
+ // setting EGL_ALPHA_SIZE to 8 results in eglChooseConfig failing
+ configAttribs.PushBack( 0 );
+#endif // _ARCH_ARM_
+
+ configAttribs.PushBack( EGL_DEPTH_SIZE );
+ configAttribs.PushBack( 24 );
+ configAttribs.PushBack( EGL_STENCIL_SIZE );
+ configAttribs.PushBack( 8 );
+ configAttribs.PushBack( EGL_SAMPLES );
+ configAttribs.PushBack( 4 );
+ configAttribs.PushBack( EGL_SAMPLE_BUFFERS );
+ configAttribs.PushBack( 1 );
+ configAttribs.PushBack( EGL_NONE );
+
+ if ( eglChooseConfig( mEglDisplay, &(configAttribs[0]), &mEglConfig, 1, &numConfigs ) != EGL_TRUE )
+ {
+ EGLint error = eglGetError();
+ switch (error)
+ {
+ case EGL_BAD_DISPLAY:
+ {
+ DALI_LOG_ERROR("Display is not an EGL display connection");
+ break;
+ }
+ case EGL_BAD_ATTRIBUTE:
+ {
+ DALI_LOG_ERROR("The parameter confirAttribs contains an invalid frame buffer configuration attribute or an attribute value that is unrecognized or out of range");
+ break;
+ }
+ case EGL_NOT_INITIALIZED:
+ {
+ DALI_LOG_ERROR("Display has not been initialized");
+ break;
+ }
+ case EGL_BAD_PARAMETER:
+ {
+ DALI_LOG_ERROR("The parameter numConfig is NULL");
+ break;
+ }
+ default:
+ {
+ DALI_LOG_ERROR("Unknown error");
+ }
+ }
+ DALI_ASSERT_ALWAYS(false && "eglChooseConfig failed!");
+ }
+
+ if ( numConfigs != 1 )
+ {
+ DALI_LOG_ERROR("No configurations found.");
+
+ TEST_EGL_ERROR("eglChooseConfig");
+ }
+}
+
+
+void EglImplementation::CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth )
+{
+ DALI_ASSERT_ALWAYS( ( mEglSurface == 0 ) && "EGL surface already exists" );
+
+ mEglNativeWindow = window;
+ mColorDepth = depth;
+ mIsWindow = true;
+
+ // egl choose config
+ ChooseConfig(mIsWindow, mColorDepth);
+
+ mEglSurface = eglCreateWindowSurface( mEglDisplay, mEglConfig, mEglNativeWindow, NULL );
+ TEST_EGL_ERROR("eglCreateWindowSurface");
+
+ DALI_ASSERT_ALWAYS( mEglSurface && "Create window surface failed" );
+}
+
+void EglImplementation::CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth )
+{
+ DALI_ASSERT_ALWAYS( mEglSurface == 0 && "Cannot create more than one instance of surface pixmap" );
+
+ mEglNativePixmap = pixmap;
+ mColorDepth = depth;
+ mIsWindow = false;
+
+ // egl choose config
+ ChooseConfig(mIsWindow, mColorDepth);
+
+ mEglSurface = eglCreatePixmapSurface( mEglDisplay, mEglConfig, mEglNativePixmap, NULL );
+ TEST_EGL_ERROR("eglCreatePixmapSurface");
+
+ DALI_ASSERT_ALWAYS( mEglSurface && "Create pixmap surface failed" );
+}
+
+bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window, EGLNativeDisplayType display )
+{
+ bool contextLost = false;
+
+ // the surface is bound to the context, so set the context to null
+ MakeContextNull();
+
+ // destroy the surface
+ DestroySurface();
+
+ // If the display has not changed, then we can just create a new surface
+ if ( display == mEglNativeDisplay )
+ {
+ // create the EGL surface
+ CreateSurfaceWindow( window, mColorDepth );
+
+ // set the context to be current with the new surface
+ MakeContextCurrent();
+ }
+ else // the display has changed, we need to start egl with a new x-connection
+ {
+ // Note! this code path is untested
+
+ // this will release all EGL specific resources
+ eglTerminate( mEglDisplay );
+
+ mGlesInitialized = false;
+
+ // let the adaptor know that all resources have been lost
+ contextLost = true;
+
+ // re-initialise GLES with the new connection
+ InitializeGles( display );
+
+ // create the EGL surface
+ CreateSurfaceWindow( window, mColorDepth );
+
+ // create the OpenGL context
+ CreateContext();
+
+ // Make it current
+ MakeContextCurrent();
+ }
+
+ return contextLost;
+}
+
+bool EglImplementation::ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLNativeDisplayType display )
+{
+ bool contextLost = false;
+
+ // the surface is bound to the context, so set the context to null
+ MakeContextNull();
+
+ // destroy the surface
+ DestroySurface();
+
+ // If the display has not changed, then we can just create a new surface
+ if ( display == mEglNativeDisplay )
+ {
+ // create the EGL surface
+ CreateSurfacePixmap( pixmap, mColorDepth );
+
+ // set the context to be current with the new surface
+ MakeContextCurrent();
+ }
+ else // the display has changed, we need to start egl with a new x-connection
+ {
+ // Note! this code path is untested
+
+ // this will release all EGL specific resources
+ eglTerminate( mEglDisplay );
+
+ mGlesInitialized = false;
+
+ // let the adaptor know that all resources have been lost
+ contextLost = true;
+
+ // re-initialise GLES with the new connection
+ InitializeGles( display );
+
+ // create the EGL surface
+ CreateSurfacePixmap( pixmap, mColorDepth );
+
+ // create the OpenGL context
+ CreateContext();
+
+ // Make it current
+ MakeContextCurrent();
+ }
+ return contextLost;
+}
+
+EGLDisplay EglImplementation::GetDisplay() const
+{
+ return mEglDisplay;
+}
+
+EGLDisplay EglImplementation::GetContext() const
+{
+ return mEglContext;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <events/event-handler.h>
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+#include <Ecore_Input.h>
+#include <ecore-wl-render-surface.h>
+#include <cstring>
+
+#include <sys/time.h>
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/events/touch-point.h>
+#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/events/mouse-wheel-event.h>
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/events/key-event-integ.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/mouse-wheel-event-integ.h>
+
+// INTERNAL INCLUDES
+#include <events/gesture-manager.h>
+#include <window-render-surface.h>
+#include <clipboard-impl.h>
+#include <key-impl.h>
+#include <physical-keyboard-impl.h>
+#include <style-monitor-impl.h>
+#include <base/core-event-interface.h>
+
+using namespace std;
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+#if defined(DEBUG_ENABLED)
+namespace
+{
+Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH");
+Integration::Log::Filter* gClientMessageLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_CLIENT_MESSAGE");
+Integration::Log::Filter* gDragAndDropLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DND");
+Integration::Log::Filter* gImfLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_IMF");
+Integration::Log::Filter* gSelectionEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_SELECTION");
+} // unnamed namespace
+#endif
+
+
+namespace
+{
+// Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead.
+size_t Utf8SequenceLength(const unsigned char leadByte)
+{
+ size_t length = 0;
+
+ if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero)
+ {
+ length = 1;
+ }
+ else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
+ {
+ length = 2;
+ }
+ else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
+ {
+ length = 3;
+ }
+ else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
+ {
+ length = 4;
+ }
+ else
+ {
+ DALI_LOG_WARNING("Unrecognized lead byte %c\n", leadByte);
+ }
+
+ return length;
+}
+
+const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
+
+const unsigned int BYTES_PER_CHARACTER_FOR_ATTRIBUTES = 3;
+
+/**
+ * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
+ * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
+ * @param[in] ecoreModifier the Ecore_Event_Modifier input.
+ * @return the Ecore_IMF_Keyboard_Modifiers output.
+ */
+Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
+{
+ int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
+
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
+ }
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
+ }
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
+ }
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
+ }
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
+ }
+
+ return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
+}
+
+
+// Copied from x server
+static unsigned int GetCurrentMilliSeconds(void)
+{
+ struct timeval tv;
+
+ struct timespec tp;
+ static clockid_t clockid;
+
+ if (!clockid)
+ {
+#ifdef CLOCK_MONOTONIC_COARSE
+ if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
+ (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
+ {
+ clockid = CLOCK_MONOTONIC_COARSE;
+ }
+ else
+#endif
+ if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+ {
+ clockid = CLOCK_MONOTONIC;
+ }
+ else
+ {
+ clockid = ~0L;
+ }
+ }
+ if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
+ {
+ return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
+ }
+
+ gettimeofday(&tv, NULL);
+ return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
+}
+
+const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
+
+} // unnamed namespace
+
+// Impl to hide EFL implementation.
+struct EventHandler::Impl
+{
+ // Construction & Destruction
+
+ /**
+ * Constructor
+ */
+ Impl( EventHandler* handler, Ecore_Wl_Window* window )
+ : mHandler( handler ),
+ mEcoreEventHandler(),
+ mWindow( window )
+ {
+ // Only register for touch and key events if we have a window
+ if ( window != 0 )
+ {
+ // Register Touch events
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, handler ) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, handler ) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, handler ) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_OUT, EcoreEventMouseButtonUp, handler ) ); // process mouse out event like up event
+
+ // Register Mouse wheel events
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, handler ) );
+
+ // Register Key events
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, handler ) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, handler ) );
+
+ // Register Vconf notify - font name and size
+ vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontNameChanged, handler );
+ vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, handler );
+ }
+ }
+
+ /**
+ * Destructor
+ */
+ ~Impl()
+ {
+ vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
+ vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontNameChanged );
+
+ for( std::vector<Ecore_Event_Handler*>::iterator iter = mEcoreEventHandler.begin(), endIter = mEcoreEventHandler.end(); iter != endIter; ++iter )
+ {
+ ecore_event_handler_del( *iter );
+ }
+ }
+
+ // Static methods
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ // Touch Callbacks
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Called when a touch down is received.
+ */
+ static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
+ {
+ Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
+ {
+ TouchPoint::State state ( TouchPoint::Down );
+
+ // Check if the buttons field is set and ensure it's the primary touch button.
+ // If this event was triggered by buttons other than the primary button (used for touch), then
+ // just send an interrupted event to Core.
+ if ( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
+ {
+ state = TouchPoint::Interrupted;
+ }
+
+ TouchPoint point( touchEvent->multi.device, state, touchEvent->x, touchEvent->y );
+ handler->SendEvent( point, touchEvent->timestamp );
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a touch up is received.
+ */
+ static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
+ {
+ Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
+ {
+ TouchPoint point( touchEvent->multi.device, TouchPoint::Up, touchEvent->x, touchEvent->y );
+ handler->SendEvent( point, touchEvent->timestamp );
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a touch up is received.
+ */
+ static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
+ {
+ Ecore_Event_Mouse_Wheel *mouseWheelEvent( (Ecore_Event_Mouse_Wheel*)event );
+
+ DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT Ecore_Event_Mouse_Wheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z);
+
+ EventHandler* handler( (EventHandler*)data );
+ if ( mouseWheelEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
+ {
+ MouseWheelEvent wheelEvent(mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
+ handler->SendMouseWheelEvent( wheelEvent );
+ }
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a touch motion is received.
+ */
+ static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
+ {
+ Ecore_Event_Mouse_Move *touchEvent( (Ecore_Event_Mouse_Move*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
+ {
+ TouchPoint point( touchEvent->multi.device, TouchPoint::Motion, touchEvent->x, touchEvent->y );
+ handler->SendEvent( point, touchEvent->timestamp );
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ // Key Callbacks
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Called when a key down is received.
+ */
+ static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyDown \n" );
+
+ EventHandler* handler( (EventHandler*)data );
+ Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
+ bool eventHandled( false );
+
+ Ecore_IMF_Context* imfContext = NULL;
+ if ( Dali::Adaptor::IsAvailable() && handler->mImfManager )
+ {
+ imfContext = reinterpret_cast<Ecore_IMF_Context*>( handler->mImfManager.GetContext() );
+ }
+
+ // If a device key then skip ecore_imf_context_filter_event.
+ if ( imfContext && !( KeyLookup::IsDeviceButton( keyEvent->keyname ) ) )
+ {
+ // We're consuming key down event so we have to pass to IMF so that it can parse it as well.
+ Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
+ ecoreKeyDownEvent.keyname = keyEvent->keyname;
+ ecoreKeyDownEvent.key = keyEvent->key;
+ ecoreKeyDownEvent.string = keyEvent->string;
+ ecoreKeyDownEvent.compose = keyEvent->compose;
+ ecoreKeyDownEvent.timestamp = keyEvent->timestamp;
+ ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
+ ecoreKeyDownEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
+
+ eventHandled = ecore_imf_context_filter_event( imfContext,
+ ECORE_IMF_EVENT_KEY_DOWN,
+ (Ecore_IMF_Event *) &ecoreKeyDownEvent );
+
+ // If the event has not been handled by IMF then check if we should reset our IMF context
+ if( !eventHandled )
+ {
+ if ( !strcmp( keyEvent->keyname, "Escape" ) ||
+ !strcmp( keyEvent->keyname, "Return" ) ||
+ !strcmp( keyEvent->keyname, "KP_Enter" ) )
+ {
+ ecore_imf_context_reset( imfContext );
+ }
+ }
+ }
+
+ // If the event wasn't handled then we should send a key event.
+ if ( !eventHandled )
+ {
+ if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
+ {
+ std::string keyName( keyEvent->keyname );
+ std::string keyString( "" );
+ int keyCode = 0/*ecore_x_keysym_keycode_get(keyEvent->keyname)*/;
+ int modifier( keyEvent->modifiers );
+ unsigned long time = keyEvent->timestamp;
+
+ if (!strncmp(keyEvent->keyname, "Keycode-", 8))
+ keyCode = atoi(keyEvent->keyname + 8);
+
+ // Ensure key event string is not NULL as keys like SHIFT have a null string.
+ if ( keyEvent->string )
+ {
+ keyString = keyEvent->string;
+ }
+
+ KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, KeyEvent::Down);
+ handler->SendEvent( keyEvent );
+ }
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a key up is received.
+ */
+ static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyUp \n" );
+
+ EventHandler* handler( (EventHandler*)data );
+ Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
+ bool eventHandled( false );
+
+ Ecore_IMF_Context* imfContext = NULL;
+ if ( Dali::Adaptor::IsAvailable() && handler->mImfManager )
+ {
+ imfContext = reinterpret_cast<Ecore_IMF_Context*>( handler->mImfManager.GetContext() );
+ }
+
+ // XF86Stop and XF86Send must skip ecore_imf_context_filter_event.
+ if ( imfContext && strcmp( keyEvent->keyname, "XF86Send" ) && strcmp( keyEvent->keyname, "XF86Phone" ) && strcmp( keyEvent->keyname, "XF86Stop" ) )
+
+ {
+ // We're consuming key up event so we have to pass to IMF so that it can parse it as well.
+ Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
+ ecoreKeyUpEvent.keyname = keyEvent->keyname;
+ ecoreKeyUpEvent.key = keyEvent->key;
+ ecoreKeyUpEvent.string = keyEvent->string;
+ ecoreKeyUpEvent.compose = keyEvent->compose;
+ ecoreKeyUpEvent.timestamp = keyEvent->timestamp;
+ ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
+ ecoreKeyUpEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
+
+ eventHandled = ecore_imf_context_filter_event( imfContext,
+ ECORE_IMF_EVENT_KEY_UP,
+ (Ecore_IMF_Event *) &ecoreKeyUpEvent );
+ }
+
+ // If the event wasn't handled then we should send a key event.
+ if ( !eventHandled )
+ {
+ if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
+ {
+ std::string keyName( keyEvent->keyname );
+ std::string keyString( "" );
+ int keyCode = 0/*ecore_x_keysym_keycode_get(keyEvent->keyname)*/;
+ int modifier( keyEvent->modifiers );
+ unsigned long time( keyEvent->timestamp );
+
+ if (!strncmp(keyEvent->keyname, "Keycode-", 8))
+ keyCode = atoi(keyEvent->keyname + 8);
+
+ // Ensure key event string is not NULL as keys like SHIFT have a null string.
+ if ( keyEvent->string )
+ {
+ keyString = keyEvent->string;
+ }
+
+ KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, KeyEvent::Up);
+ handler->SendEvent( keyEvent );
+ }
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ // Window Callbacks
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Called when the window gains focus.
+ */
+ static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
+ {
+ Ecore_Wl_Event_Focus_In* focusInEvent( (Ecore_Wl_Event_Focus_In*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusIn \n" );
+
+ // If the window gains focus and we hid the keyboard then show it again.
+ if ( focusInEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
+ {
+ DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventWindowFocusIn - >>WindowFocusGained \n" );
+
+ if ( handler->mImfManager )
+ {
+ ImfManager& imfManager( ImfManager::GetImplementation( handler->mImfManager ) );
+ if( imfManager.RestoreAfterFocusLost() )
+ {
+ imfManager.Activate();
+ }
+ }
+ // No need to connect callbacks as KeyboardStatusChanged will be called.
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the window loses focus.
+ */
+ static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
+ {
+ Ecore_Wl_Event_Focus_Out* focusOutEvent( (Ecore_Wl_Event_Focus_Out*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusOut \n" );
+
+ // If the window loses focus then hide the keyboard.
+ if ( focusOutEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
+ {
+ if ( handler->mImfManager )
+ {
+ ImfManager& imfManager( ImfManager::GetImplementation( handler->mImfManager ) );
+ if( imfManager.RestoreAfterFocusLost() )
+ {
+ imfManager.Deactivate();
+ }
+ }
+
+ // Clipboard don't support that whether clipboard is shown or not. Hide clipboard.
+ Dali::Clipboard clipboard = Clipboard::Get();
+ clipboard.HideClipboard();
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the window is damaged.
+ */
+ static Eina_Bool EcoreEventWindowDamaged(void *data, int type, void *event)
+ {
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the window properties are changed.
+ * We are only interested in the font change.
+ */
+
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ // Drag & Drop Callbacks
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Called when a dragged item enters our window's bounds.
+ * This is when items are dragged INTO our window.
+ */
+ static Eina_Bool EcoreEventDndEnter( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO( gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndEnter\n" );
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a dragged item is moved within our window.
+ * This is when items are dragged INTO our window.
+ */
+ static Eina_Bool EcoreEventDndPosition( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndPosition\n" );
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a dragged item leaves our window's bounds.
+ * This is when items are dragged INTO our window.
+ */
+ static Eina_Bool EcoreEventDndLeave( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndLeave\n" );
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the dragged item is dropped within our window's bounds.
+ * This is when items are dragged INTO our window.
+ */
+ static Eina_Bool EcoreEventDndDrop( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndDrop\n" );
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a dragged item is moved from our window and the target window has done processing it.
+ * This is when items are dragged FROM our window.
+ */
+ static Eina_Bool EcoreEventDndFinished( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndFinished\n" );
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a dragged item is moved from our window and the target window has sent us a status.
+ * This is when items are dragged FROM our window.
+ */
+ static Eina_Bool EcoreEventDndStatus( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndStatus\n" );
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the client messages (i.e. the accessibility events) are received.
+ */
+ static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
+ {
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the source window notifies us the content in clipboard is selected.
+ */
+ static Eina_Bool EcoreEventSelectionClear( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionClear\n" );
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the source window sends us about the selected content.
+ * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
+ */
+ static Eina_Bool EcoreEventSelectionNotify( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionNotify\n" );
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ // Font Callbacks
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Called when a font name is changed.
+ */
+ static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
+ {
+ EventHandler* handler = static_cast<EventHandler*>( data );
+
+ StyleChange fontChange;
+ fontChange.defaultFontChange = true;
+
+ handler->SendEvent( fontChange );
+ }
+
+ /**
+ * Called when a font size is changed.
+ */
+ static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
+ {
+ EventHandler* handler = static_cast<EventHandler*>( data );
+
+ StyleChange fontChange;
+ fontChange.defaultFontSizeChange = true;
+
+ handler->SendEvent( fontChange );
+ }
+
+ // Data
+ EventHandler* mHandler;
+ std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
+ Ecore_Wl_Window* mWindow;
+};
+
+EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
+: mCoreEventInterface(coreEventInterface),
+ mGestureManager( gestureManager ),
+ mStyleMonitor( StyleMonitor::Get() ),
+ mDamageObserver( damageObserver ),
+ mRotationObserver( NULL ),
+ mDragAndDropDetector( dndDetector ),
+ mAccessibilityManager( AccessibilityManager::Get() ),
+ mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
+ mClipboard(Clipboard::Get()),
+ mImfManager( ImfManager::Get() ),
+ mImpl( NULL )
+{
+ Ecore_Wl_Window* window = 0;
+
+ if( surface->GetType() == Dali::RenderSurface::WINDOW )
+ {
+ // this code only works with the Ecore RenderSurface so need to downcast
+ ECore::WindowRenderSurface* ecoreSurface = dynamic_cast< ECore::WindowRenderSurface* >( surface );
+ if( ecoreSurface )
+ {
+ window = ecoreSurface->GetWlWindow();
+ }
+ }
+
+ mImpl = new Impl(this, window);
+}
+
+EventHandler::~EventHandler()
+{
+ if(mImpl)
+ {
+ delete mImpl;
+ }
+
+ mGestureManager.Stop();
+}
+
+void EventHandler::SendEvent(TouchPoint& point, unsigned long timeStamp)
+{
+ if(timeStamp < 1)
+ {
+ timeStamp = GetCurrentMilliSeconds();
+ }
+
+ Integration::TouchEvent event;
+ if (mCombiner.GetNextTouchEvent(point, timeStamp, event))
+ {
+ DALI_LOG_INFO(gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.deviceId, point.state, point.local.x, point.local.y);
+
+ // First the touch event & related gesture events are queued
+ mCoreEventInterface.QueueCoreEvent( event );
+ mGestureManager.SendEvent(event);
+
+ // Next the events are processed with a single call into Core
+ mCoreEventInterface.ProcessCoreEvents();
+ }
+}
+
+void EventHandler::SendEvent(KeyEvent& keyEvent)
+{
+ Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
+ if ( physicalKeyboard )
+ {
+ if ( ! KeyLookup::IsDeviceButton( keyEvent.keyPressedName.c_str() ) )
+ {
+ GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
+ }
+ }
+
+ // Create KeyEvent and send to Core.
+ Integration::KeyEvent event(keyEvent.keyPressedName, keyEvent.keyPressed, keyEvent.keyCode,
+ keyEvent.keyModifier, keyEvent.time, static_cast<Integration::KeyEvent::State>(keyEvent.state));
+ mCoreEventInterface.QueueCoreEvent( event );
+ mCoreEventInterface.ProcessCoreEvents();
+}
+
+void EventHandler::SendMouseWheelEvent( MouseWheelEvent& wheelEvent )
+{
+ // Create MouseWheelEvent and send to Core.
+ Integration::MouseWheelEvent event(wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp);
+ mCoreEventInterface.QueueCoreEvent( event );
+ mCoreEventInterface.ProcessCoreEvents();
+}
+
+void EventHandler::SendEvent(StyleChange styleChange)
+{
+ DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
+ GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
+}
+
+void EventHandler::SendEvent( const DamageArea& area )
+{
+ mDamageObserver.OnDamaged( area );
+}
+
+void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
+{
+ if( mRotationObserver != NULL )
+ {
+ mRotationObserver->OnRotationPrepare( event );
+ }
+}
+
+void EventHandler::SendRotationRequestEvent( )
+{
+ if( mRotationObserver != NULL )
+ {
+ mRotationObserver->OnRotationRequest( );
+ }
+}
+
+void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
+{
+ SendEvent(point, timeStamp);
+}
+
+void EventHandler::FeedWheelEvent( MouseWheelEvent& wheelEvent )
+{
+ SendMouseWheelEvent( wheelEvent );
+}
+
+void EventHandler::FeedKeyEvent( KeyEvent& event )
+{
+ SendEvent( event );
+}
+
+void EventHandler::FeedEvent( Integration::Event& event )
+{
+ mCoreEventInterface.QueueCoreEvent( event );
+ mCoreEventInterface.ProcessCoreEvents();
+}
+
+void EventHandler::Reset()
+{
+ mCombiner.Reset();
+
+ // Any touch listeners should be told of the interruption.
+ Integration::TouchEvent event;
+ TouchPoint point(0, TouchPoint::Interrupted, 0, 0);
+ event.AddPoint( point );
+
+ // First the touch event & related gesture events are queued
+ mCoreEventInterface.QueueCoreEvent( event );
+ mGestureManager.SendEvent( event );
+
+ // Next the events are processed with a single call into Core
+ mCoreEventInterface.ProcessCoreEvents();
+}
+
+void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
+{
+ mDragAndDropDetector = detector;
+}
+
+void EventHandler::SetRotationObserver( RotationObserver* observer )
+{
+ mRotationObserver = observer;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+# wayland
+
+adaptor_wayland_internal_header_files = \
+ $(adaptor_wayland_dir)/clipboard-impl.h \
+ $(adaptor_wayland_dir)/imf-manager-impl.h \
+ $(adaptor_wayland_dir)/pixmap-image-impl.h \
+ $(adaptor_wayland_dir)/pixmap-render-surface.h
+
+adaptor_wayland_application_src_files = \
+ $(adaptor_wayland_dir)/framework-wl.cpp
+
+adaptor_wayland_internal_src_files = \
+ $(adaptor_wayland_dir)/accessibility-manager-impl-wl.cpp \
+ $(adaptor_wayland_dir)/clipboard-impl-wl.cpp \
+ $(adaptor_wayland_dir)/imf-manager-impl-wl.cpp \
+ $(adaptor_wayland_dir)/pixmap-image-impl-wl.cpp \
+ $(adaptor_wayland_dir)/server-connection-wl.cpp \
+ $(adaptor_wayland_dir)/system-settings-wl.cpp \
+ $(adaptor_wayland_dir)/virtual-keyboard-impl-wl.cpp \
+ $(adaptor_wayland_dir)/window-impl-wl.cpp \
+ $(adaptor_wayland_dir)/event-handler-wl.cpp \
+ $(adaptor_wayland_dir)/egl-implementation-wl.cpp \
+ $(adaptor_wayland_dir)/ecore-wl-render-surface.cpp \
+ $(adaptor_wayland_dir)/pixmap-render-surface-wl.cpp \
+ $(adaptor_wayland_dir)/window-render-surface-wl.cpp
+
+adaptor_wayland_profile_src_files = \
+ $(adaptor_wayland_dir)/key-impl-wl.cpp \
+ $(adaptor_wayland_dir)/ecore-wl-render-surface-factory.cpp
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "framework.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+void Framework::InitThreads()
+{
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <imf-manager-impl.h>
+
+// EXTERNAL INCLUDES
+#include <boost/bind.hpp>
+#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/object/type-registry.h>
+#include <adaptor.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <window-render-surface.h>
+#include <adaptor-impl.h>
+#include <virtual-keyboard-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_IMF_MANAGER");
+#endif
+
+// Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead.
+size_t Utf8SequenceLength(const unsigned char leadByte)
+{
+ size_t length = 0;
+
+ if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero)
+ {
+ length = 1;
+ }
+ else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
+ {
+ length = 2;
+ }
+ else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
+ {
+ length = 3;
+ }
+ else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
+ {
+ length = 4;
+ }
+
+ return length;
+}
+
+// Static function calls used by ecore 'c' style callback registration
+void Commit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
+{
+ if ( data )
+ {
+ ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
+ imfManager->CommitReceived( data, imfContext, event_info );
+ }
+}
+
+void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
+{
+ if ( data )
+ {
+ ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
+ imfManager->PreEditChanged( data, imfContext, event_info );
+ }
+}
+
+Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
+{
+ if ( data )
+ {
+ ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
+ return imfManager->RetrieveSurrounding( data, imfContext, text, cursorPosition );
+ }
+ else
+ {
+ return false;
+ }
+}
+
+/**
+ * Called when an IMF delete surrounding event is received.
+ * Here we tell the application that it should delete a certain range.
+ */
+void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
+{
+ if ( data )
+ {
+ ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
+ imfManager->DeleteSurrounding( data, imfContext, event_info );
+ }
+}
+
+BaseHandle Create()
+{
+ BaseHandle handle( ImfManager::Get() );
+
+ return handle;
+}
+
+TypeRegistration IMF_MANAGER_TYPE( typeid(Dali::ImfManager), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
+
+} // unnamed namespace
+
+Dali::ImfManager ImfManager::Get()
+{
+ Dali::ImfManager manager;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::ImfManager ) );
+ if(handle)
+ {
+ // If so, downcast the handle
+ manager = Dali::ImfManager( dynamic_cast< ImfManager* >( handle.GetObjectPtr() ) );
+ }
+ }
+
+ return manager;
+}
+
+ImfManager::~ImfManager()
+{
+ VirtualKeyboard::DisconnectCallbacks( mIMFContext );
+ DisconnectCallbacks();
+
+ DeleteContext();
+ ecore_imf_shutdown();
+}
+
+void ImfManager::DeleteContext()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteContext\n" );
+
+ if ( mIMFContext )
+ {
+ mIMFContext = NULL;
+ }
+}
+
+// Callbacks for predicitive text support.
+void ImfManager::ConnectCallbacks()
+{
+ if ( mIMFContext )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::ConnectCallbacks\n" );
+
+ ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this );
+ ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this );
+ ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this );
+
+ ecore_imf_context_retrieve_surrounding_callback_set( mIMFContext, ImfRetrieveSurrounding, this);
+ }
+}
+
+void ImfManager::DisconnectCallbacks()
+{
+ if ( mIMFContext )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DisconnectCallbacks\n" );
+
+ ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit );
+ ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit );
+ ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding );
+
+ // We do not need to unset the retrieve surrounding callback.
+ }
+}
+
+void ImfManager::Activate()
+{
+ // Reset mIdleCallbackConnected
+ mIdleCallbackConnected = false;
+
+ if ( mIMFContext )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Activate\n" );
+
+ ecore_imf_context_focus_in( mIMFContext );
+
+ // emit keyboard activated signal
+ Dali::ImfManager handle( this );
+ mActivatedSignalV2.Emit( handle );
+ }
+}
+
+void ImfManager::Deactivate()
+{
+ if( mIMFContext )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Deactivate\n" );
+
+ Reset();
+ ecore_imf_context_focus_out( mIMFContext );
+ }
+
+ // Reset mIdleCallbackConnected
+ mIdleCallbackConnected = false;
+}
+
+void ImfManager::Reset()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Reset\n" );
+
+ if ( mIMFContext )
+ {
+ ecore_imf_context_reset( mIMFContext );
+ }
+}
+
+Ecore_IMF_Context* ImfManager::GetContext()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetContext\n" );
+
+ return mIMFContext;
+}
+
+bool ImfManager::RestoreAfterFocusLost() const
+{
+ return mRestoreAfterFocusLost;
+}
+
+void ImfManager::SetRestoreAferFocusLost( bool toggle )
+{
+ mRestoreAfterFocusLost = toggle;
+}
+
+/**
+ * Called when an IMF Pre-Edit changed event is received.
+ * We are still predicting what the user is typing. The latest string is what the IMF module thinks
+ * the user wants to type.
+ */
+void ImfManager::PreEditChanged( void *, Ecore_IMF_Context *imfContext, void *event_info )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::PreEditChanged\n" );
+
+ char *preEditString( NULL );
+ int cursorPosition( 0 );
+ Eina_List *attrs = NULL;
+ Eina_List *l = NULL;
+
+ Ecore_IMF_Preedit_Attr *attr;
+
+ // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.
+ // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.
+ ecore_imf_context_preedit_string_with_attributes_get( imfContext, &preEditString, &attrs, &cursorPosition );
+
+ if ( attrs )
+ {
+ // iterate through the list of attributes getting the type, start and end position.
+ for ( l = attrs, (attr = (Ecore_IMF_Preedit_Attr*)eina_list_data_get(l) ); l; l = eina_list_next(l), ( attr = (Ecore_IMF_Preedit_Attr*)eina_list_data_get(l) ))
+ {
+ if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF)
+ {
+ // check first byte so know how many bytes a character is represented by as keyboard returns cursor position in bytes. Which is different for some languages.
+
+ size_t visualCharacterIndex = 0;
+ size_t byteIndex = 0;
+
+ // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
+ while ( preEditString[byteIndex] != '\0' )
+ {
+ // attr->end_index is provided as a byte position not character and we need to know the character position.
+ size_t currentSequenceLength = Utf8SequenceLength(preEditString[byteIndex]); // returns number of bytes used to represent character.
+ if ( byteIndex == attr->end_index )
+ {
+ cursorPosition = visualCharacterIndex;
+ break;
+ // end loop as found cursor position that matches byte position
+ }
+ else
+ {
+ byteIndex += currentSequenceLength; // jump to next character
+ visualCharacterIndex++; // increment character count so we know our position for when we get a match
+ }
+
+ DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString ));
+ }
+ }
+ }
+ }
+
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ std::string keyString ( preEditString );
+ int numberOfChars( 0 );
+
+ Dali::ImfManager handle( this );
+ Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::PREEDIT, keyString, cursorPosition, numberOfChars );
+ Dali::ImfManager::ImfCallbackData callbackData = mEventSignalV2.Emit( handle, imfEventData );
+
+ if ( callbackData.update )
+ {
+ SetCursorPosition( callbackData.cursorPosition );
+ SetSurroundingText( callbackData.currentText );
+
+ NotifyCursorPosition();
+ }
+
+ if ( callbackData.preeditResetRequired )
+ {
+ Reset();
+ }
+ }
+ free( preEditString );
+}
+
+void ImfManager::CommitReceived( void *, Ecore_IMF_Context *imfContext, void *event_info )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CommitReceived\n" );
+
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ const std::string keyString( (char *)event_info );
+ const int cursorOffset( 0 );
+ const int numberOfChars( 0 );
+
+ Dali::ImfManager handle( this );
+ Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::COMMIT, keyString, cursorOffset, numberOfChars );
+ Dali::ImfManager::ImfCallbackData callbackData = mEventSignalV2.Emit( handle, imfEventData );
+
+ if ( callbackData.update )
+ {
+ SetCursorPosition( callbackData.cursorPosition );
+ SetSurroundingText( callbackData.currentText );
+
+ NotifyCursorPosition();
+ }
+ }
+}
+
+/**
+ * Called when an IMF retrieve surround event is received.
+ * Here the IMF module wishes to know the string we are working with and where within the string the cursor is
+ * We need to signal the application to tell us this information.
+ */
+Eina_Bool ImfManager::RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::RetrieveSurrounding\n" );
+
+ std::string keyString ( "" );
+ int cursorOffset( 0 );
+ int numberOfChars( 0 );
+
+ Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::GETSURROUNDING , keyString, cursorOffset, numberOfChars );
+ Dali::ImfManager handle( this );
+ mEventSignalV2.Emit( handle, imfData );
+
+ if ( text )
+ {
+ std::string surroundingText( GetSurroundingText() );
+
+ if ( !surroundingText.empty() )
+ {
+ *text = strdup( surroundingText.c_str() );
+ }
+ else
+ {
+ *text = strdup( "" );
+ }
+ }
+
+ if ( cursorPosition )
+ {
+ *cursorPosition = GetCursorPosition();
+ }
+
+
+ return EINA_TRUE;
+}
+
+/**
+ * Called when an IMF delete surrounding event is received.
+ * Here we tell the application that it should delete a certain range.
+ */
+void ImfManager::DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteSurrounding\n" );
+
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = (Ecore_IMF_Event_Delete_Surrounding*) event_info;
+
+ const std::string keyString( "" );
+ const int cursorOffset( deleteSurroundingEvent->offset );
+ const int numberOfChars( deleteSurroundingEvent->n_chars );
+
+ Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::DELETESURROUNDING , keyString, cursorOffset, numberOfChars );
+ Dali::ImfManager handle( this );
+ mEventSignalV2.Emit( handle, imfData );
+ }
+}
+
+void ImfManager::NotifyCursorPosition()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::NotifyCursorPosition\n" );
+
+ if ( mIMFContext )
+ {
+ ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
+ }
+}
+
+int ImfManager::GetCursorPosition()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetCursorPosition\n" );
+
+ return mIMFCursorPosition;
+}
+
+void ImfManager::SetCursorPosition( unsigned int cursorPosition )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetCursorPosition\n" );
+
+ mIMFCursorPosition = ( int )cursorPosition;
+}
+
+void ImfManager::SetSurroundingText( std::string text )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetSurroundingText\n" );
+
+ mSurroundingText = text;
+}
+
+std::string ImfManager::GetSurroundingText()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetSurroundingText\n" );
+
+ return mSurroundingText;
+}
+
+} // Adaptor
+
+} // Internal
+
+} // Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_IMF_MANAGER_H
+#define __DALI_INTERNAL_IMF_MANAGER_H
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <Ecore_IMF.h>
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+
+#include <dali/public-api/object/base-object.h>
+#include <imf-manager.h>
+#include <dali/integration-api/events/key-event-integ.h>
+
+// INTERNAL INCLUDES
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class RenderSurface;
+
+class ImfManager : public Dali::BaseObject
+{
+public:
+ typedef Dali::ImfManager::ImfManagerSignalV2 ImfManagerSignalV2;
+ typedef Dali::ImfManager::ImfEventSignalV2 ImfEventSignalV2;
+
+public:
+
+ /**
+ * Create the IMF manager.
+ */
+ static Dali::ImfManager Get();
+
+ /**
+ * Connect Callbacks required for IMF.
+ * If you don't connect imf callbacks, you can't get the key events.
+ * The events are PreeditChanged, Commit and DeleteSurrounding.
+ */
+ void ConnectCallbacks();
+
+ /**
+ * Disconnect Callbacks attached to imf context.
+ */
+ void DisconnectCallbacks();
+
+ /**
+ * @copydoc Dali::ImfManager::Activate()
+ */
+ void Activate();
+
+ /**
+ * @copydoc Dali::ImfManager::Deactivate()
+ */
+ void Deactivate();
+
+ /**
+ * @copydoc Dali::ImfManager::Reset()
+ */
+ void Reset();
+
+ /**
+ * @copydoc Dali::ImfManager::GetContext()
+ */
+ Ecore_IMF_Context* GetContext();
+
+ /**
+ * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
+ */
+ bool RestoreAfterFocusLost() const;
+
+ /**
+ * @copydoc Dali::ImfManager::SetRestoreAferFocusLost()
+ */
+ void SetRestoreAferFocusLost( bool toggle );
+
+ /**
+ * @copydoc Dali::ImfManager::PreEditChanged()
+ */
+ void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
+
+ /**
+ * @copydoc Dali::ImfManager::NotifyCursorPosition()
+ */
+ void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
+
+ /**
+ * @copydoc Dali::ImfManager::NotifyCursorPosition()
+ */
+ Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
+
+ /**
+ * @copydoc Dali::ImfManager::DeleteSurrounding()
+ */
+ void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
+
+ // Cursor related
+ /**
+ * @copydoc Dali::ImfManager::NotifyCursorPosition()
+ */
+ void NotifyCursorPosition();
+
+ /**
+ * @copydoc Dali::ImfManager::GetCursorPosition()
+ */
+ int GetCursorPosition();
+
+ /**
+ * @copydoc Dali::ImfManager::SetCursorPosition()
+ */
+ void SetCursorPosition( unsigned int cursorPosition );
+
+ /**
+ * @copydoc Dali::ImfManager::SetSurroundingText()
+ */
+ void SetSurroundingText( std::string text );
+
+ /**
+ * @copydoc Dali::ImfManager::GetSurroundingText()
+ */
+ std::string GetSurroundingText();
+
+public: // Signals
+
+ /**
+ * @copydoc Dali::ImfManager::ActivatedSignal()
+ */
+ ImfManagerSignalV2& ActivatedSignal() { return mActivatedSignalV2; }
+
+ /**
+ * @copydoc Dali::ImfManager::EventReceivedSignal()
+ */
+ ImfEventSignalV2& EventReceivedSignal() { return mEventSignalV2; }
+
+protected:
+
+ /**
+ * Destructor.
+ */
+ virtual ~ImfManager();
+
+private:
+ /**
+ * @copydoc Dali::ImfManager::DeleteContext()
+ */
+ void DeleteContext();
+
+private:
+ // Undefined
+ ImfManager( const ImfManager& );
+ ImfManager& operator=( ImfManager& );
+
+private:
+ Ecore_IMF_Context* mIMFContext;
+ int mIMFCursorPosition;
+ std::string mSurroundingText;
+
+ bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
+ bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
+
+ std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
+
+ ImfManagerSignalV2 mActivatedSignalV2;
+ ImfEventSignalV2 mEventSignalV2;
+
+public:
+
+inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
+{
+ DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
+
+ BaseObject& handle = imfManager.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::ImfManager&>(handle);
+}
+
+inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
+{
+ DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
+
+ const BaseObject& handle = imfManager.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::ImfManager&>(handle);
+}
+
+};
+
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_IMF_MANAGER_H
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "key-impl.h"
+
+// EXTERNAL INCLUDES
+#include <map>
+#include <string.h>
+#include <iostream>
+
+
+#include <dali/integration-api/debug.h>
+
+
+namespace Dali
+{
+
+const KEY DALI_KEY_INVALID = -1;
+const KEY DALI_KEY_ESCAPE = 9;
+const KEY DALI_KEY_BACK = 166;
+const KEY DALI_KEY_CAMERA = 167;
+const KEY DALI_KEY_CONFIG = 168;
+const KEY DALI_KEY_POWER = 169;
+const KEY DALI_KEY_PAUSE = 170;
+const KEY DALI_KEY_CANCEL = 171;
+const KEY DALI_KEY_PLAY_CD = 172;
+const KEY DALI_KEY_STOP_CD = 173;
+const KEY DALI_KEY_PAUSE_CD = 174;
+const KEY DALI_KEY_NEXT_SONG = 175;
+const KEY DALI_KEY_PREVIOUS_SONG = 176;
+const KEY DALI_KEY_REWIND = 177;
+const KEY DALI_KEY_FASTFORWARD = 178;
+const KEY DALI_KEY_MEDIA = 179;
+const KEY DALI_KEY_PLAY_PAUSE = 180;
+const KEY DALI_KEY_MUTE = 181;
+const KEY DALI_KEY_SEND = 182;
+const KEY DALI_KEY_SELECT = 183;
+const KEY DALI_KEY_END = DALI_KEY_BACK;
+const KEY DALI_KEY_MENU = DALI_KEY_SEND;
+const KEY DALI_KEY_HOME = DALI_KEY_SELECT;
+const KEY DALI_KEY_HOMEPAGE = 187;
+const KEY DALI_KEY_WEBPAGE = 188;
+const KEY DALI_KEY_MAIL = 189;
+const KEY DALI_KEY_SCREENSAVER = 190;
+const KEY DALI_KEY_BRIGHTNESS_UP = 191;
+const KEY DALI_KEY_BRIGHTNESS_DOWN = 192;
+const KEY DALI_KEY_SOFT_KBD = 193;
+const KEY DALI_KEY_QUICK_PANEL = 194;
+const KEY DALI_KEY_TASK_SWITCH = 195;
+const KEY DALI_KEY_APPS = 196;
+const KEY DALI_KEY_SEARCH = 197;
+const KEY DALI_KEY_VOICE = 198;
+const KEY DALI_KEY_LANGUAGE = 199;
+const KEY DALI_KEY_VOLUME_UP = 200;
+const KEY DALI_KEY_VOLUME_DOWN = 201;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace KeyLookup
+{
+
+namespace
+{
+
+struct KeyLookup
+{
+ const char* keyName; ///< X string representation
+ const int daliKeyCode; ///< Dali Enum Representation
+ const bool deviceButton; ///< Whether the key is from a button on the device
+};
+
+// matches a DALI_KEY enum, to a X key name
+KeyLookup KeyLookupTable[]=
+{
+ // more than one key name can be assigned to a single dali-key code
+ // e.g. Menu and KEY_MENU("FS86KeyMenu") are both assigned to DALI_KEY_MENU
+
+ { "Escape", DALI_KEY_ESCAPE, false }, // item not defined in utilX
+ { "Menu", DALI_KEY_MENU, false }, // item not defined in utilX
+};
+
+const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable))/ (sizeof(KeyLookup));
+
+class KeyMap
+{
+ public:
+
+ KeyMap():
+ mLookup( cmpString )
+ {
+ // create the lookup
+ for( size_t i = 0; i < KEY_LOOKUP_COUNT ; ++i )
+ {
+ const KeyLookup& keyLookup( KeyLookupTable[i] );
+ mLookup[ keyLookup.keyName ] = DaliKeyType( keyLookup.daliKeyCode, keyLookup.deviceButton );
+ }
+ }
+
+ int GetDaliKeyEnum( const char* keyName ) const
+ {
+ Lookup::const_iterator i = mLookup.find( keyName );
+ if( i == mLookup.end() )
+ {
+ return -1;
+ }
+ else
+ {
+ return (*i).second.first;
+ }
+ }
+
+ bool IsDeviceButton( const char* keyName ) const
+ {
+ Lookup::const_iterator i = mLookup.find( keyName );
+ if ( i != mLookup.end() )
+ {
+ return (*i).second.second;
+ }
+ return false;
+ }
+
+ private:
+
+ /**
+ * compare function, to compare string by pointer
+ */
+ static bool cmpString( const char* a, const char* b)
+ {
+ return strcmp(a, b) < 0;
+ }
+
+ typedef std::pair< int, bool > DaliKeyType;
+ typedef std::map<const char* /* key name */, DaliKeyType /* key code */, bool(*) ( char const* a, char const* b) > Lookup;
+ Lookup mLookup;
+
+};
+const KeyMap globalKeyLookup;
+
+} // un-named name space
+
+bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey)
+{
+ int key = globalKeyLookup.GetDaliKeyEnum( keyEvent.keyPressedName.c_str() );
+ return daliKey == key;
+}
+
+bool IsDeviceButton( const char* keyName )
+{
+ return globalKeyLookup.IsDeviceButton( keyName );
+}
+
+} // namespace KeyLookup
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "pixmap-image-impl.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+#include <dali/integration-api/debug.h>
+#include <render-surface.h>
+
+// INTERNAL INCLUDES
+#include <gl/egl-image-extensions.h>
+#include <gl/egl-factory.h>
+#include <adaptor-impl.h>
+
+// Allow this to be encoded and saved:
+#include <platform-abstractions/slp/resource-loader/resource-loader.h>
+#include <platform-abstractions/slp/resource-loader/loader-jpeg.h>
+#include <platform-abstractions/slp/resource-loader/loader-png.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+using Dali::Integration::PixelBuffer;
+
+// Pieces needed to save compressed images (temporary location while plumbing):
+namespace
+{
+
+ /**
+ * Simple function to tell intended image file format from filename
+ */
+ FileFormat GetFormatFromFileName( const std::string& filename )
+ {
+ if (filename.length() < 5)
+ {
+ DALI_LOG_WARNING("Invalid (short) filename.");
+ }
+ FileFormat format(INVALID_FORMAT);
+
+ const std::size_t filenameSize = filename.length();
+
+ if(filenameSize >= 4){ // Avoid throwing out_of_range or failing silently if exceptions are turned-off on the compare(). (http://www.cplusplus.com/reference/string/string/compare/)
+ if( !filename.compare( filenameSize - 4, 4, ".jpg" )
+ || !filename.compare( filenameSize - 4, 4, ".JPG" ) )
+ {
+ format = JPG_FORMAT;
+ }
+ else if( !filename.compare( filenameSize - 4, 4, ".png" )
+ || !filename.compare( filenameSize - 4, 4, ".PNG" ) )
+ {
+ format = PNG_FORMAT;
+ }
+ else if( !filename.compare( filenameSize - 4, 4, ".bmp" )
+ || !filename.compare( filenameSize - 4, 4, ".BMP" ) )
+ {
+ format = BMP_FORMAT;
+ }
+ else if( !filename.compare( filenameSize - 4, 4, ".gif" )
+ || !filename.compare( filenameSize - 4, 4, ".GIF" ) )
+ {
+ format = GIF_FORMAT;
+ }
+ else if( !filename.compare( filenameSize - 4, 4, ".ico" )
+ || !filename.compare( filenameSize - 4, 4, ".ICO" ) )
+ {
+ format = ICO_FORMAT;
+ }
+ else if(filenameSize >= 5){
+ if( !filename.compare( filenameSize - 5, 5, ".jpeg" )
+ || !filename.compare( filenameSize - 5, 5, ".JPEG" ) )
+ {
+ format = JPG_FORMAT;
+ }
+ }
+ }
+
+ return format;
+ }
+
+ bool EncodeToFormat( const PixelBuffer* pixelBuffer, std::vector< unsigned char >& encodedPixels, FileFormat formatEncoding, std::size_t width, std::size_t height, Pixel::Format pixelFormat )
+ {
+ switch( formatEncoding )
+ {
+ case JPG_FORMAT:
+ {
+ return SlpPlatform::EncodeToJpeg( pixelBuffer, encodedPixels, width, height, pixelFormat );
+ break;
+ }
+ case PNG_FORMAT:
+ {
+ return SlpPlatform::EncodeToPng( pixelBuffer, encodedPixels, width, height, pixelFormat );
+ break;
+ }
+ default:
+ {
+ DALI_LOG_ERROR("Format not supported for image encoding (supported formats are PNG and JPEG)");
+ break;
+ }
+ }
+ return false;
+ }
+
+ bool EncodeToFile(const PixelBuffer * const pixelBuffer, const std::string& filename, const Pixel::Format pixelFormat, const std::size_t width, const std::size_t height)
+ {
+ DALI_ASSERT_DEBUG(pixelBuffer != 0 && filename.size() > 4 && width > 0 && height > 0);
+ std::vector< unsigned char > pixbufEncoded;
+ const FileFormat format = GetFormatFromFileName( filename );
+ const bool encodeResult = EncodeToFormat( pixelBuffer, pixbufEncoded, format, width, height, pixelFormat );
+ if(!encodeResult)
+ {
+ DALI_LOG_ERROR("Encoding pixels failed");
+ return false;
+ }
+ return SlpPlatform::ResourceLoader::SaveFile( filename, pixbufEncoded );
+ }
+}
+
+PixmapImage* PixmapImage::New(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Dali::Adaptor& adaptor, Any pixmap )
+{
+ PixmapImage* image = new PixmapImage( width, height, depth, adaptor, pixmap );
+ DALI_ASSERT_DEBUG( image && "PixmapImage allocation failed." );
+
+ // 2nd phase construction
+ if(image) //< Defensive in case we ever compile without exceptions.
+ {
+ image->Initialize();
+ }
+
+ return image;
+}
+
+PixmapImage::PixmapImage(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Dali::Adaptor& adaptor, Any pixmap)
+: mWidth(width),
+ mHeight(height),
+ mOwnPixmap(true),
+ mPixelFormat(Pixel::RGB888),
+ mColorDepth(depth),
+ mAdaptor(Internal::Adaptor::Adaptor::GetImplementation(adaptor)),
+ mEglImageKHR(NULL)
+{
+}
+
+void PixmapImage::Initialize()
+{
+}
+
+PixmapImage::~PixmapImage()
+{
+ // Lost the opportunity to call GlExtensionDestroy() if Adaptor is destroyed first
+ if( Adaptor::IsAvailable() )
+ {
+ // GlExtensionDestroy() called from GLCleanup on the render thread. Checking this is done here.
+ // (mEglImageKHR is now read/written from different threads although ref counted destruction
+ // should mean this isnt concurrent)
+ DALI_ASSERT_ALWAYS( NULL == mEglImageKHR && "NativeImage GL resources have not been properly cleaned up" );
+ }
+}
+
+Any PixmapImage::GetPixmap(Dali::PixmapImage::PixmapAPI api) const
+{
+ return NULL;
+}
+
+Any PixmapImage::GetDisplay() const
+{
+ return NULL;
+}
+
+bool PixmapImage::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
+{
+ return false;
+}
+
+bool PixmapImage::EncodeToFile(const std::string& filename) const
+{
+ std::vector< unsigned char > pixbuf;
+ unsigned int width(0), height(0);
+ Pixel::Format pixelFormat;
+
+ if(GetPixels(pixbuf, width, height, pixelFormat))
+ {
+ return Dali::Internal::Adaptor::EncodeToFile(&pixbuf[0], filename, pixelFormat, width, height);
+ }
+ return false;
+}
+
+bool PixmapImage::GlExtensionCreate()
+{
+ return false;
+}
+
+void PixmapImage::GlExtensionDestroy()
+{
+ EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
+
+ eglImageExtensions->DestroyImageKHR(mEglImageKHR);
+
+ mEglImageKHR = NULL;
+}
+
+unsigned int PixmapImage::TargetTexture()
+{
+ EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
+
+ eglImageExtensions->TargetTextureKHR(mEglImageKHR);
+
+ return 0;
+}
+
+int PixmapImage::GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const
+{
+ switch (depth)
+ {
+ case Dali::PixmapImage::COLOR_DEPTH_8:
+ {
+ return 8;
+ }
+ case Dali::PixmapImage::COLOR_DEPTH_16:
+ {
+ return 16;
+ }
+ case Dali::PixmapImage::COLOR_DEPTH_24:
+ {
+ return 24;
+ }
+ case Dali::PixmapImage::COLOR_DEPTH_32:
+ {
+ return 32;
+ }
+ default:
+ {
+ DALI_ASSERT_DEBUG(0 && "unknown color enum");
+ return 0;
+ }
+ }
+}
+
+void PixmapImage::SetPixelFormat(int depth)
+{
+ // store the pixel format based on the depth
+ switch (depth)
+ {
+ case 8:
+ {
+ mPixelFormat = Pixel::A8;
+ break;
+ }
+ case 16:
+ {
+ mPixelFormat = Pixel::RGB565;
+ break;
+ }
+ case 32:
+ {
+ mPixelFormat = Pixel::RGBA8888;
+ break;
+ }
+ case 24:
+ default:
+ {
+ mPixelFormat = Pixel::RGB888;
+ break;
+ }
+ }
+}
+
+void PixmapImage::GetPixmapDetails()
+{
+}
+
+EglImageExtensions* PixmapImage::GetEglImageExtensions() const
+{
+ EglFactory& factory = mAdaptor.GetEGLFactory();
+ EglImageExtensions* egl = factory.GetImageExtensions();
+ DALI_ASSERT_DEBUG( egl && "EGL Image Extensions not initialized" );
+ return egl;
+}
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_PIXMAP_IMAGE_H__
+#define __DALI_INTERNAL_PIXMAP_IMAGE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+#include <pixmap-image.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class Adaptor;
+class EglImageExtensions;
+
+/**
+ * Dali internal PixmapImage.
+ */
+class PixmapImage
+{
+public:
+
+ /**
+ * Create a new PixmapImage internally.
+ * Depending on hardware the width and height may have to be a power of two.
+ * @param[in] width The width of the image.
+ * @param[in] height The height of the image.
+ * @param[in] depth color depth of the pixmap
+ * @param[in] adaptor reference to dali adaptor
+ * @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
+ * @return A smart-pointer to a newly allocated image.
+ */
+ static PixmapImage* New(unsigned int width,
+ unsigned int height,
+ Dali::PixmapImage::ColorDepth depth,
+ Dali::Adaptor& adaptor,
+ Any pixmap);
+
+ /**
+ * @copydoc Dali::PixmapImage::GetPixmap()
+ */
+ Any GetPixmap(Dali::PixmapImage::PixmapAPI api) const;
+
+ /**
+ * @copydoc Dali::PixmapImage::GetDisplay()
+ */
+ Any GetDisplay() const;
+
+ /**
+ * @copydoc Dali::PixmapImage::GetPixels()
+ */
+ bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
+
+ /**
+ * @copydoc Dali::PixmapImage::EncodeToFile(const std::string& )
+ */
+ bool EncodeToFile(const std::string& filename) const;
+
+ /**
+ * destructor
+ */
+ ~PixmapImage();
+
+ /**
+ * @copydoc Dali::PixmapImage::GlExtensionCreate()
+ */
+ bool GlExtensionCreate();
+
+ /**
+ * @copydoc Dali::PixmapImage::GlExtensionDestroy()
+ */
+ void GlExtensionDestroy();
+
+ /**
+ * @copydoc Dali::PixmapImage::TargetTexture()
+ */
+ unsigned int TargetTexture();
+
+ /**
+ * @copydoc Dali::PixmapImage::GetWidth()
+ */
+ unsigned int GetWidth() const
+ {
+ return mWidth;
+ }
+
+ /**
+ * @copydoc Dali::PixmapImage::GetHeight()
+ */
+ unsigned int GetHeight() const
+ {
+ return mHeight;
+ }
+
+ /**
+ * @copydoc Dali::PixmapImage::GetPixelFormat()
+ */
+ Pixel::Format GetPixelFormat() const
+ {
+ return mPixelFormat;
+ }
+
+private:
+
+ /**
+ * Private constructor; @see PixmapImage::New()
+ * @param[in] width The width of the image.
+ * @param[in] height The height of the image.
+ * @param[in] colour depth of the pixmap
+ * @param[in] adaptor a reference to Dali adaptor
+ * @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
+ */
+ PixmapImage(unsigned int width,
+ unsigned int height,
+ Dali::PixmapImage::ColorDepth depth,
+ Dali::Adaptor &adaptor,
+ Any pixmap);
+
+ /**
+ * 2nd phase construction.
+ */
+ void Initialize();
+
+ /**
+ * Uses X11 to get the default depth.
+ * @param depth the PixelImage depth enum
+ * @return default x11 pixel depth
+ */
+ int GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const;
+
+ /**
+ * Sets the pixel format based on the bit depth
+ * @param depth depth in bytes
+ */
+ void SetPixelFormat(int depth);
+
+ /**
+ * Given an existing pixmap, the function uses X to find out
+ * the width, heigth and depth of that pixmap.
+ */
+ void GetPixmapDetails();
+
+ /**
+ * Returns the egl image extensions class from the adaptor
+ * @return reference to egl image extensionsa
+ */
+ EglImageExtensions* GetEglImageExtensions() const;
+
+private:
+
+ unsigned int mWidth; ///< pixmap width
+ unsigned int mHeight; ///< pixmap heights
+ bool mOwnPixmap; ///< Whether we created pixmap or not
+ Pixel::Format mPixelFormat; ///< pixmap pixel format
+ Dali::PixmapImage::ColorDepth mColorDepth; ///< color depth of pixmap
+ Adaptor& mAdaptor; ///< adaptor
+ void* mEglImageKHR; ///< From EGL extension
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_PIXMAP_IMAGE_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "pixmap-render-surface.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/gl-abstraction.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <ecore-wl-types.h>
+#include <trigger-event.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+#if defined(DEBUG_ENABLED)
+extern Debug::Filter* gRenderSurfaceLogFilter;
+#endif
+
+namespace ECore
+{
+
+PixmapRenderSurface::PixmapRenderSurface( Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent)
+: RenderSurface( Dali::RenderSurface::PIXMAP, positionSize, surface, display, name, isTransparent )
+{
+ Init( surface );
+}
+
+PixmapRenderSurface::~PixmapRenderSurface()
+{
+ // release the surface if we own one
+ if( mOwnSurface )
+ {
+ // if we did create the pixmap, delete the pixmap
+ DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::General, "Own pixmap (%x) freed\n", mX11Pixmap );
+ }
+}
+
+Dali::RenderSurface::SurfaceType PixmapRenderSurface::GetType()
+{
+ return Dali::RenderSurface::PIXMAP;
+}
+
+Any PixmapRenderSurface::GetSurface()
+{
+ return Any( NULL );
+}
+
+void PixmapRenderSurface::InitializeEgl( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+ eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
+
+ eglImpl.ChooseConfig(false, mColorDepth);
+}
+
+void PixmapRenderSurface::CreateEglSurface( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ //EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+
+ // create the EGL surface
+ // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
+ // FIXME
+}
+
+void PixmapRenderSurface::DestroyEglSurface( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+ eglImpl.DestroySurface();
+}
+
+bool PixmapRenderSurface::ReplaceEGLSurface( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+ eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
+
+ // a new surface for the new pixmap
+ // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
+ // FIXME
+ return false;
+}
+
+bool PixmapRenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& )
+{
+ // nothing to do for pixmaps
+ return true;
+}
+
+void PixmapRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode )
+{
+ // flush gl instruction queue
+ glAbstraction.Flush();
+
+ // create damage for client applications which wish to know the update timing
+ if( mRenderNotification )
+ {
+ // use notification trigger
+ // Tell the event-thread to render the pixmap
+ mRenderNotification->Trigger();
+ }
+ else
+ {
+ // as a fallback, send damage event. This is needed until livebox is fixed to
+ // stop using damage events for render
+ // FIXME
+ }
+
+ // Do render synchronisation
+ DoRenderSync( timeDelta, syncMode );
+}
+
+void PixmapRenderSurface::CreateWlRenderable()
+{
+ // check we're creating one with a valid size
+ DALI_ASSERT_ALWAYS( mPosition.width > 0 && mPosition.height > 0 && "Pixmap size is invalid" );
+
+ // FIXME
+}
+
+void PixmapRenderSurface::UseExistingRenderable( unsigned int surfaceId )
+{
+}
+
+void PixmapRenderSurface::RenderSync()
+{
+ {
+ boost::unique_lock< boost::mutex > lock( mSyncMutex );
+ mSyncReceived = true;
+ }
+
+ // wake render thread if it was waiting for the notify
+ mSyncNotify.notify_all();
+}
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ECORE_X_PIXMAP_RENDER_SURFACE_H__
+#define __DALI_INTERNAL_ECORE_X_PIXMAP_RENDER_SURFACE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <ecore-wl-render-surface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class TriggerEvent;
+
+namespace ECore
+{
+
+/**
+ * Ecore X11 implementation of render surface.
+ */
+class PixmapRenderSurface : public RenderSurface
+{
+public:
+
+ /**
+ * Uses an Wayland surface to render to.
+ * @param [in] positionSize the position and size of the surface
+ * @param [in] surface can be a Wayland-window (type must be unsigned int).
+ * @param [in] display connection to Wayland-server if the surface is a X window or pixmap (type must be void * to X display struct)
+ * @param [in] name optional name of surface passed in
+ * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
+ */
+ PixmapRenderSurface( Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent = false);
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface::~RenderSurface
+ */
+ virtual ~PixmapRenderSurface();
+
+public: // API
+
+public: // from Dali::RenderSurface
+
+ /**
+ * @copydoc Dali::RenderSurface::GetType()
+ */
+ virtual Dali::RenderSurface::SurfaceType GetType();
+
+ /**
+ * @copydoc Dali::RenderSurface::GetSurface()
+ */
+ virtual Any GetSurface();
+
+public: // from Internal::Adaptor::RenderSurface
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::InitializeEgl()
+ */
+ virtual void InitializeEgl( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface()
+ */
+ virtual void CreateEglSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface()
+ */
+ virtual void DestroyEglSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface()
+ */
+ virtual bool ReplaceEGLSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::RenderSync()
+ */
+ virtual void RenderSync();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::PreRender()
+ */
+ virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::PostRender()
+ */
+ virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode );
+
+private:
+
+ /**
+ * Create XPixmap
+ */
+ virtual void CreateWlRenderable();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface::UseExistingRenderable
+ */
+ virtual void UseExistingRenderable( unsigned int surfaceId );
+
+private: // Data
+
+};
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ECORE_X_PIXMAP_RENDER_SURFACE_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "server-connection.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+#if defined(DEBUG_ENABLED)
+extern Debug::Filter* gIndicatorLogFilter;
+#endif
+
+
+ServerConnection::ServerConnection(
+ const char* serviceName,
+ int serviceNumber,
+ bool isSystem,
+ ServerConnection::Observer* observer)
+
+: mConnected(false),
+ mObserver(observer)
+{
+ ecore_ipc_init();
+ mService.name = eina_stringshare_add(serviceName);
+ mService.num = serviceNumber;
+ mService.isSystem = isSystem;
+
+ DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "ServerConnection: Connecting to %s %d\n", mService.name, mService.num );
+
+ mIpcServer = NULL;
+
+ if( !mIpcServer )
+ {
+ ecore_ipc_shutdown();
+ }
+ else
+ {
+ mIpcHandlers.push_back( ecore_event_handler_add( ECORE_IPC_EVENT_SERVER_ADD,
+ &ServerConnection::IpcServerAdd,
+ this ) );
+
+ mIpcHandlers.push_back( ecore_event_handler_add( ECORE_IPC_EVENT_SERVER_DEL,
+ &ServerConnection::IpcServerDel,
+ this ) );
+
+ mIpcHandlers.push_back( ecore_event_handler_add( ECORE_IPC_EVENT_SERVER_DATA,
+ &ServerConnection::IpcServerData,
+ this));
+
+ mConnected = true;
+ }
+}
+
+} // Adaptor
+} // Internal
+} // Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <system_settings.h>
+#include <Elementary.h>
+
+// INTERNAL INCLUDES
+#include "system-settings.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+int GetElmAccessActionOver()
+{
+ return 0;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "virtual-keyboard-impl.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+#include <algorithm>
+
+#include <dali/public-api/common/vector-wrapper.h>
+#include <adaptor.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <locale-utils.h>
+#include <imf-manager-impl.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace VirtualKeyboard
+{
+
+void RotateTo(int angle)
+{
+}
+
+} // namespace VirtualKeyboard
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "window-impl.h"
+
+// EXTERNAL HEADERS
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+
+#include <dali/integration-api/core.h>
+#include <dali/integration-api/system-overlay.h>
+#include <dali/public-api/render-tasks/render-task.h>
+#include <dali/public-api/render-tasks/render-task-list.h>
+#include <orientation.h>
+
+// INTERNAL HEADERS
+#include <window-render-surface.h>
+#include <drag-and-drop-detector-impl.h>
+#include <indicator-impl.h>
+#include <window-visibility-observer.h>
+#include <orientation-impl.h>
+
+namespace
+{
+const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
+const float INDICATOR_SHOW_Y_POSITION( 0.0f );
+const float INDICATOR_HIDE_Y_POSITION( -52.0f );
+}
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_WINDOW");
+#endif
+
+/**
+ * TODO: Abstract Window class out and move this into a window implementation for Ecore
+ */
+struct Window::EventHandler
+{
+ /**
+ * Constructor
+ * @param[in] window A pointer to the window class.
+ */
+ EventHandler( Window* window )
+ : mWindow( window ),
+ mEcoreWindow( 0 )
+ {
+ }
+
+ /**
+ * Destructor
+ */
+ ~EventHandler()
+ {
+ if ( mWindowPropertyHandler )
+ {
+ ecore_event_handler_del( mWindowPropertyHandler );
+ }
+ if ( mClientMessagehandler )
+ {
+ ecore_event_handler_del( mClientMessagehandler );
+ }
+ }
+
+ // Static methods
+
+ /// Called when the window properties are changed.
+ static Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
+ {
+ return EINA_FALSE;
+ }
+
+ /// Called when the window properties are changed.
+ static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
+ {
+ return EINA_FALSE;
+ }
+
+ // Data
+ Window* mWindow;
+ Ecore_Event_Handler* mWindowPropertyHandler;
+ Ecore_Event_Handler* mClientMessagehandler;
+ Ecore_Wl_Window* mEcoreWindow;
+};
+
+
+Window* Window::New(const PositionSize& posSize, const std::string& name, bool isTransparent)
+{
+ Window* window = new Window();
+ window->mIsTransparent = isTransparent;
+ window->Initialize(posSize, name);
+ return window;
+}
+
+void Window::SetAdaptor(Dali::Adaptor& adaptor)
+{
+ DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
+ mStarted = true;
+
+ // Only create one overlay per window
+ Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
+ Integration::Core& core = adaptorImpl.GetCore();
+ mOverlay = &core.GetSystemOverlay();
+
+ Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
+ taskList.CreateTask();
+
+ mAdaptor = &adaptorImpl;
+ mAdaptor->AddObserver( *this );
+
+ // Can only create the detector when we know the Core has been instantiated.
+ mDragAndDropDetector = DragAndDropDetector::New();
+ mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
+
+ if( mOrientation )
+ {
+ mOrientation->SetAdaptor(adaptor);
+ }
+
+ if( mIndicator != NULL )
+ {
+ mIndicator->SetAdaptor(mAdaptor);
+ }
+}
+
+RenderSurface* Window::GetSurface()
+{
+ return mSurface;
+}
+
+void Window::SetIndicatorStyle( Dali::Window::IndicatorStyle style )
+{
+ mIndicatorStyle = style;
+}
+
+void Window::ShowIndicator( bool show )
+{
+ DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "%s\n", show?"SHOW":"HIDE" );
+ DALI_ASSERT_DEBUG(mOverlay);
+
+ if(show)
+ {
+ mIndicatorVisible = Dali::Window::VISIBLE;
+ }
+ else
+ {
+ mIndicatorVisible = Dali::Window::INVISIBLE;
+ }
+
+ DoShowIndicator( mIndicatorOrientation );
+}
+
+void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
+{
+ DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
+ DALI_ASSERT_DEBUG(mOverlay);
+
+ DoShowIndicator( mIndicatorOrientation );
+}
+
+void Window::RotateIndicator(Dali::Window::WindowOrientation orientation)
+{
+ DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
+
+ DoRotateIndicator( orientation );
+}
+
+void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
+{
+ mIndicatorOpacityMode = opacityMode;
+
+ if( mIndicator != NULL )
+ {
+ mIndicator->SetOpacityMode( opacityMode );
+ }
+}
+
+void Window::SetClass(std::string name, std::string klass)
+{
+}
+
+Window::Window()
+: mSurface(NULL),
+ mIndicatorStyle(Dali::Window::CHANGEABLE_COLOR),
+ mIndicatorVisible(Dali::Window::VISIBLE),
+ mIndicatorIsShown(false),
+ mShowRotatedIndicatorOnClose(false),
+ mStarted(false),
+ mIsTransparent(false),
+ mWMRotationAppSet(false),
+ mIndicator(NULL),
+ mIndicatorOrientation(Dali::Window::PORTRAIT),
+ mNextIndicatorOrientation(Dali::Window::PORTRAIT),
+ mIndicatorOpacityMode(Dali::Window::OPAQUE),
+ mOverlay(NULL),
+ mAdaptor(NULL)
+{
+}
+
+Window::~Window()
+{
+ delete mEventHandler;
+
+ if ( mAdaptor )
+ {
+ mAdaptor->RemoveObserver( *this );
+ mAdaptor->SetDragAndDropDetector( NULL );
+ mAdaptor = NULL;
+ }
+
+ delete mSurface;
+}
+
+void Window::Initialize(const PositionSize& windowPosition, const std::string& name)
+{
+ // create an Wayland window by default
+ Any surface;
+ Any display;
+ mSurface = new ECore::WindowRenderSurface( windowPosition, surface, display, name, mIsTransparent );
+ mOrientation = Orientation::New(this);
+
+ // create event handler for Wayland window
+ mEventHandler = new EventHandler( this );
+}
+
+void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
+{
+ if( mIndicator == NULL )
+ {
+ if( mIndicatorVisible != Dali::Window::INVISIBLE )
+ {
+ mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, mIndicatorStyle, this );
+ mIndicator->SetOpacityMode( mIndicatorOpacityMode );
+ Dali::Actor actor = mIndicator->GetActor();
+ SetIndicatorActorRotation();
+ mOverlay->Add(actor);
+ }
+ // else don't create a hidden indicator
+ }
+ else // Already have indicator
+ {
+ if( mIndicatorVisible == Dali::Window::VISIBLE )
+ {
+ // If we are resuming, and rotation has changed,
+ if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
+ {
+ // then close current indicator and open new one
+ mShowRotatedIndicatorOnClose = true;
+ mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
+ // Don't show actor - will contain indicator for old orientation.
+ }
+ }
+ }
+
+ // set indicator visible mode
+ if( mIndicator != NULL )
+ {
+ mIndicator->SetVisible( mIndicatorVisible );
+ }
+
+ bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
+ SetIndicatorProperties( show, lastOrientation );
+ mIndicatorIsShown = show;
+}
+
+void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
+{
+ if( mIndicatorIsShown )
+ {
+ mShowRotatedIndicatorOnClose = true;
+ mNextIndicatorOrientation = orientation;
+ mIndicator->Close(); // May synchronously call IndicatorClosed() callback
+ }
+ else
+ {
+ // Save orientation for when the indicator is next shown
+ mShowRotatedIndicatorOnClose = false;
+ mNextIndicatorOrientation = orientation;
+ }
+}
+
+void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
+{
+}
+
+void Window::IndicatorTypeChanged(Indicator::Type type)
+{
+}
+
+void Window::IndicatorClosed( Indicator* indicator )
+{
+ DALI_LOG_TRACE_METHOD( gWindowLogFilter );
+
+ if( mShowRotatedIndicatorOnClose )
+ {
+ Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
+ mIndicator->Open(mNextIndicatorOrientation);
+ mIndicatorOrientation = mNextIndicatorOrientation;
+ SetIndicatorActorRotation();
+ DoShowIndicator(currentOrientation);
+ }
+}
+
+void Window::SetIndicatorActorRotation()
+{
+ DALI_LOG_TRACE_METHOD( gWindowLogFilter );
+ DALI_ASSERT_DEBUG( mIndicator != NULL );
+
+ Dali::Actor actor = mIndicator->GetActor();
+ switch( mIndicatorOrientation )
+ {
+ case Dali::Window::PORTRAIT:
+ actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
+ actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ actor.SetRotation( Degree(0), Vector3::ZAXIS );
+ break;
+ case Dali::Window::PORTRAIT_INVERSE:
+ actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
+ actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ actor.SetRotation( Degree(180), Vector3::ZAXIS );
+ break;
+ case Dali::Window::LANDSCAPE:
+ actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
+ actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ actor.SetRotation( Degree(270), Vector3::ZAXIS );
+ break;
+ case Dali::Window::LANDSCAPE_INVERSE:
+ actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
+ actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ actor.SetRotation( Degree(90), Vector3::ZAXIS );
+ break;
+ }
+}
+
+void Window::Raise()
+{
+}
+
+void Window::Lower()
+{
+}
+
+void Window::Activate()
+{
+}
+
+Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
+{
+ return mDragAndDropDetector;
+}
+
+void Window::OnStart()
+{
+ DoShowIndicator( mIndicatorOrientation );
+}
+
+void Window::OnPause()
+{
+}
+
+void Window::OnResume()
+{
+ // resume indicator status
+ if( mIndicator != NULL )
+ {
+ // Restore own indicator opacity
+ // Send opacity mode to indicator service when app resumed
+ mIndicator->SetOpacityMode( mIndicatorOpacityMode );
+ }
+}
+
+void Window::OnStop()
+{
+ if( mIndicator )
+ {
+ mIndicator->Close();
+ }
+
+ delete mIndicator;
+ mIndicator = NULL;
+}
+
+void Window::OnDestroy()
+{
+ mAdaptor = NULL;
+}
+
+OrientationPtr Window::GetOrientation()
+{
+ return mOrientation;
+}
+
+void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
+{
+ bool found = false;
+
+ for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
+ {
+ if(mAvailableOrientations[i] == orientation)
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if( ! found )
+ {
+ mAvailableOrientations.push_back(orientation);
+ SetAvailableOrientations( mAvailableOrientations );
+ }
+}
+
+void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
+{
+ for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
+ iter != mAvailableOrientations.end(); ++iter )
+ {
+ if( *iter == orientation )
+ {
+ mAvailableOrientations.erase( iter );
+ break;
+ }
+ }
+ SetAvailableOrientations( mAvailableOrientations );
+}
+
+void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
+{
+ DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
+}
+
+const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
+{
+ return mAvailableOrientations;
+}
+
+void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
+{
+ mPreferredOrientation = orientation;
+}
+
+Dali::Window::WindowOrientation Window::GetPreferredOrientation()
+{
+ return mPreferredOrientation;
+}
+
+void Window::RotationDone( int orientation, int width, int height )
+{
+}
+
+
+} // Adaptor
+} // Internal
+} // Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "window-render-surface.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/gl-abstraction.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <ecore-wl-types.h>
+#include <trigger-event.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+#if defined(DEBUG_ENABLED)
+extern Debug::Filter* gRenderSurfaceLogFilter;
+#endif
+
+namespace ECore
+{
+
+namespace
+{
+
+const int MINIMUM_DIMENSION_CHANGE( 1 ); ///< Minimum change for window to be considered to have moved
+
+} // unnamed namespace
+
+WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent)
+: RenderSurface( Dali::RenderSurface::WINDOW, positionSize, surface, display, name, isTransparent ),
+ mNeedToApproveDeiconify(false)
+{
+ DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" );
+ Init( surface );
+}
+
+WindowRenderSurface::~WindowRenderSurface()
+{
+ if( mOwnSurface )
+ {
+ ecore_wl_window_free( mWlWindow );
+ }
+}
+
+Ecore_Wl_Window* WindowRenderSurface::GetDrawable()
+{
+ // already an e-core type
+ return mWlWindow;
+}
+
+Dali::RenderSurface::SurfaceType WindowRenderSurface::GetType()
+{
+ return Dali::RenderSurface::WINDOW;
+}
+
+Any WindowRenderSurface::GetSurface()
+{
+ // already an e-core type
+ return Any( mWlWindow );
+}
+
+Ecore_Wl_Window* WindowRenderSurface::GetWlWindow()
+{
+ return mWlWindow;
+}
+
+void WindowRenderSurface::RequestToApproveDeiconify()
+{
+ mNeedToApproveDeiconify = true;
+}
+
+void WindowRenderSurface::InitializeEgl( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+ eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
+
+ eglImpl.ChooseConfig(true, mColorDepth);
+}
+
+void WindowRenderSurface::CreateEglSurface( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+
+ // create the EGL surface
+ ecore_wl_window_surface_create(mWlWindow);
+ mEglWindow = wl_egl_window_create(ecore_wl_window_surface_get(mWlWindow), mPosition.width, mPosition.height);
+ eglImpl.CreateSurfaceWindow( (EGLNativeWindowType)mEglWindow, mColorDepth ); // reinterpret_cast does not compile
+}
+
+void WindowRenderSurface::DestroyEglSurface( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+ eglImpl.DestroySurface();
+ wl_egl_window_destroy(mEglWindow);
+ mEglWindow = NULL;
+}
+
+bool WindowRenderSurface::ReplaceEGLSurface( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& egl = static_cast<EglImplementation&>( eglIf );
+ egl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
+
+ wl_egl_window_destroy(mEglWindow);
+ mEglWindow = wl_egl_window_create(ecore_wl_window_surface_get(mWlWindow), mPosition.width, mPosition.height);
+ return egl.ReplaceSurfaceWindow( (EGLNativeWindowType)mEglWindow, // reinterpret_cast does not compile
+ reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
+}
+
+void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize )
+{
+ bool needToMove = false;
+ bool needToResize = false;
+
+ // check moving
+ if( (fabs(positionSize.x - mPosition.x) > MINIMUM_DIMENSION_CHANGE) ||
+ (fabs(positionSize.y - mPosition.y) > MINIMUM_DIMENSION_CHANGE) )
+ {
+ needToMove = true;
+ }
+
+ // check resizing
+ if( (fabs(positionSize.width - mPosition.width) > MINIMUM_DIMENSION_CHANGE) ||
+ (fabs(positionSize.height - mPosition.height) > MINIMUM_DIMENSION_CHANGE) )
+ {
+ needToResize = true;
+ }
+
+ if(needToMove)
+ {
+ ecore_wl_window_move(mWlWindow, positionSize.x, positionSize.y);
+ mPosition = positionSize;
+ }
+ if (needToResize)
+ {
+ ecore_wl_window_resize(mWlWindow, positionSize.width, positionSize.height, 0);
+ mPosition = positionSize;
+ }
+
+}
+
+void WindowRenderSurface::Map()
+{
+ ecore_wl_window_show(mWlWindow);
+}
+
+bool WindowRenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& )
+{
+ // nothing to do for windows
+ return true;
+}
+
+void WindowRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int, SyncMode )
+{
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );
+ eglImpl.SwapBuffers();
+
+ // When the window is deiconified, it approves the deiconify operation to window manager after rendering
+ if(mNeedToApproveDeiconify)
+ {
+ // SwapBuffer is desychronized. So make sure to sychronize when window is deiconified.
+ glAbstraction.Finish();
+
+ mNeedToApproveDeiconify = false;
+ }
+}
+
+void WindowRenderSurface::SetViewMode( ViewMode viewMode )
+{
+}
+
+void WindowRenderSurface::CreateWlRenderable()
+{
+ // if width or height are zero, go full screen.
+ if ( (mPosition.width == 0) || (mPosition.height == 0) )
+ {
+ // Default window size == screen size
+ mPosition.x = 0;
+ mPosition.y = 0;
+
+ ecore_wl_screen_size_get( &mPosition.width, &mPosition.height );
+ }
+
+ mWlWindow = ecore_wl_window_new( 0, mPosition.x, mPosition.y, mPosition.width, mPosition.height, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW );
+
+ if ( mWlWindow == 0 )
+ {
+ DALI_ASSERT_ALWAYS(0 && "Failed to create X window");
+ }
+}
+
+void WindowRenderSurface::UseExistingRenderable( unsigned int surfaceId )
+{
+ mWlWindow = AnyCast< Ecore_Wl_Window* >( surfaceId );
+}
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ECORE_WL_WINDOW_RENDER_SURFACE_H__
+#define __DALI_INTERNAL_ECORE_WL_WINDOW_RENDER_SURFACE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <ecore-wl-render-surface.h>
+#include <wayland-egl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECore
+{
+
+/**
+ * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface.
+ * Window specialization.
+ */
+class WindowRenderSurface : public RenderSurface
+{
+public:
+
+ /**
+ * Uses an Wayland surface to render to.
+ * @param [in] positionSize the position and size of the surface
+ * @param [in] surface can be a Wayland-window or Wayland-pixmap (type must be unsigned int).
+ * @param [in] display connection to Wayland-server if the surface is a X window or pixmap (type must be void * to X display struct)
+ * @param [in] name optional name of surface passed in
+ * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
+ */
+ WindowRenderSurface( Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent = false );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface::~RenderSurface
+ */
+ virtual ~WindowRenderSurface();
+
+public: // API
+
+ /**
+ * @copydoc Dali::RenderSurface::GetDrawable()
+ */
+ virtual Ecore_Wl_Window* GetDrawable();
+
+ /**
+ * Request to approve deiconify operation
+ * If it is requested, it will send ECORE_X_ATOM_E_DEICONIFY_APPROVE event to window manager after rendering
+ */
+ void RequestToApproveDeiconify();
+
+public: // from Dali::RenderSurface
+
+ /**
+ * @copydoc Dali::RenderSurface::GetType()
+ */
+ virtual Dali::RenderSurface::SurfaceType GetType();
+
+ /**
+ * @copydoc Dali::RenderSurface::GetSurface()
+ */
+ virtual Any GetSurface();
+
+ /**
+ * @copydoc Dali::RenderSurface::GetDrawable()
+ */
+ virtual Ecore_Wl_Window* GetWlWindow();
+
+public: // from Internal::Adaptor::RenderSurface
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::InitializeEgl()
+ */
+ virtual void InitializeEgl( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface()
+ */
+ virtual void CreateEglSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface()
+ */
+ virtual void DestroyEglSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface()
+ */
+ virtual bool ReplaceEGLSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::MoveResize()
+ */
+ virtual void MoveResize( Dali::PositionSize positionSize);
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::Map()
+ */
+ virtual void Map();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::PreRender()
+ */
+ virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::PostRender()
+ */
+ virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::SetViewMode()
+ */
+ void SetViewMode( ViewMode viewMode );
+
+protected:
+
+ /**
+ * Create WlWindow
+ */
+ virtual void CreateWlRenderable();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::ECoreX::RenderSurface::UseExistingRenderable
+ */
+ virtual void UseExistingRenderable( unsigned int surfaceId );
+
+private: // Data
+
+ Ecore_Wl_Window* mWlWindow; ///< Wayland-Window
+ wl_egl_window* mEglWindow;
+ bool mNeedToApproveDeiconify; ///< Whether need to send ECORE_X_ATOM_E_DEICONIFY_APPROVE event
+
+}; // class WindowRenderSurface
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ECORE_X_WINDOW_RENDER_SURFACE_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "accessibility-manager-impl.h"
+
+// EXTERNAL INCLUDES
+#include <vconf.h>
+#include <Ecore_X.h>
+#include <Elementary.h>
+
+#include <dali/public-api/dali-core.h>
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/gesture-requests.h>
+#include "system-settings.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace {
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gAccessibilityManagerLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_MANAGER");
+#endif
+} // unnamed namespace
+
+bool AccessibilityManager::HandleActionNextEvent(bool allowEndFeedback)
+{
+ bool ret = false;
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionNext signal in first, AccessibilityActionNext for handler in next
+ */
+ if( !mIndicatorFocused )
+ {
+ if( !mActionNextSignalV2.Empty() )
+ {
+ mActionNextSignalV2.Emit( handle );
+ }
+ }
+
+ if( mIndicator && mIndicatorFocused )
+ {
+ Elm_Access_Action_Info actionInfo;
+ actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
+
+ ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
+ }
+ else if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionPreviousEvent(bool allowEndFeedback)
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionPrevious signal in first, AccessibilityActionPrevious for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionPreviousSignalV2.Empty() )
+ {
+ mActionPreviousSignalV2.Emit( handle );
+ }
+ }
+
+ if( mIndicator && mIndicatorFocused )
+ {
+ Elm_Access_Action_Info actionInfo;
+ actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
+
+ ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
+ }
+ else if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionActivateEvent()
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionActivate signal in first, AccessibilityActionActivate for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionActivateSignalV2.Empty() )
+ {
+ mActionActivateSignalV2.Emit( handle );
+ }
+ }
+
+ if( mIndicator && mIndicatorFocused )
+ {
+ Elm_Access_Action_Info actionInfo;
+ actionInfo.action_type = ELM_ACCESS_ACTION_ACTIVATE;
+
+ ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
+ }
+ else if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionActivate();
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
+{
+ bool ret = false;
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
+
+ mReadPosition.x = x;
+ mReadPosition.y = y;
+
+ Dali::AccessibilityManager handle( this );
+
+ bool indicatorFocused = false;
+
+ // Check whether the Indicator is focused
+ if( mIndicator && mIndicator->IsConnected() )
+ {
+ // Check the position and size of Indicator actor
+ Dali::Actor indicatorActor = mIndicator->GetActor();
+ Vector3 position = Vector3(0.0f, 0.0f, 0.0f);
+ Vector3 size = indicatorActor.GetCurrentSize();
+
+ if(mReadPosition.x >= position.x &&
+ mReadPosition.x <= position.x + size.width &&
+ mReadPosition.y >= position.y &&
+ mReadPosition.y <= position.y + size.height)
+ {
+ indicatorFocused = true;
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Indicator area!!!!\n", __FUNCTION__, __LINE__);
+ }
+ }
+
+ if( mIndicator )
+ {
+ if( !mIndicatorFocused && indicatorFocused )
+ {
+ // If Indicator is focused, the focus should be cleared in Dali focus chain.
+ if( mActionHandler )
+ {
+ mActionHandler->ClearAccessibilityFocus();
+ }
+ }
+ else if( mIndicatorFocused && !indicatorFocused )
+ {
+ Elm_Access_Action_Info actionInfo;
+ actionInfo.action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
+
+ // Indicator should be unhighlighted
+ ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Send unhighlight message to indicator!!!!\n", __FUNCTION__, __LINE__);
+ }
+
+ mIndicatorFocused = indicatorFocused;
+
+ // Send accessibility READ action information to Indicator
+ if( mIndicatorFocused )
+ {
+ Elm_Access_Action_Info actionInfo;
+ actionInfo.x = mReadPosition.x;
+ actionInfo.y = mReadPosition.y;
+
+ if(allowReadAgain)
+ {
+ actionInfo.action_type = ELM_ACCESS_ACTION_READ;
+ }
+ else
+ {
+ actionInfo.action_type = static_cast<Elm_Access_Action_Type>( GetElmAccessActionOver() );
+ }
+
+ ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Send READ message to indicator!!!!\n", __FUNCTION__, __LINE__);
+ }
+ }
+
+ if(allowReadAgain)
+ {
+ /*
+ * In order to application decide reading action first,
+ * emit ActionRead signal in first, AccessibilityActionRead for handler in next
+ */
+ if( !mIndicatorFocused )
+ {
+ if ( !mActionReadSignalV2.Empty() )
+ {
+ mActionReadSignalV2.Emit( handle );
+ }
+ }
+ }
+ else
+ {
+ /*
+ * In order to application decide reading action first,
+ * emit ActionRead signal in first, AccessibilityActionRead for handler in next
+ */
+ if( !mIndicatorFocused )
+ {
+ if ( !mActionOverSignalV2.Empty() )
+ {
+ mActionOverSignalV2.Emit( handle );
+ }
+ }
+ }
+
+ if( mActionHandler && !mIndicatorFocused)
+ {
+ // If Indicator is not focused, the accessibility actions should be handled by the registered
+ // accessibility action handler (e.g. focus manager)
+ ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+ }
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionReadNextEvent(bool allowEndFeedback)
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionReadNext signal in first, AccessibilityActionReadNext for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionReadNextSignalV2.Empty() )
+ {
+ mActionReadNextSignalV2.Emit( handle );
+ }
+ }
+
+ if( mIndicator && mIndicatorFocused )
+ {
+ Elm_Access_Action_Info actionInfo;
+ actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
+
+ ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
+ }
+ else if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionReadPreviousEvent(bool allowEndFeedback)
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionReadPrevious signal in first, AccessibilityActionReadPrevious for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionReadPreviousSignalV2.Empty() )
+ {
+ mActionReadPreviousSignalV2.Emit( handle );
+ }
+ }
+
+ if( mIndicator && mIndicatorFocused )
+ {
+ Elm_Access_Action_Info actionInfo;
+ actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
+
+ ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
+ }
+ else if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionUpEvent()
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionUp signal in first, AccessibilityActionUp for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionUpSignalV2.Empty() )
+ {
+ mActionUpSignalV2.Emit( handle );
+ }
+ }
+
+ if( mIndicator && mIndicatorFocused )
+ {
+ Elm_Access_Action_Info actionInfo;
+ actionInfo.action_type = ELM_ACCESS_ACTION_UP;
+
+ ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
+ }
+ else if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionUp();
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+bool AccessibilityManager::HandleActionDownEvent()
+{
+ bool ret = false;
+
+ Dali::AccessibilityManager handle( this );
+
+ /*
+ * In order to application decide reading action first,
+ * emit ActionDown signal in first, AccessibilityActionDown for handler in next
+ */
+ if ( !mIndicatorFocused )
+ {
+ if( !mActionDownSignalV2.Empty() )
+ {
+ mActionDownSignalV2.Emit( handle );
+ }
+ }
+
+ if( mIndicator && mIndicatorFocused )
+ {
+ Elm_Access_Action_Info actionInfo;
+ actionInfo.action_type = ELM_ACCESS_ACTION_DOWN;
+
+ ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
+ }
+ else if( mActionHandler )
+ {
+ ret = mActionHandler->AccessibilityActionDown();
+ }
+
+ DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+
+ return ret;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "clipboard-impl.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore_X.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <adaptor.h>
+#include <dali/public-api/object/any.h>
+#include <adaptor-impl.h>
+#include <ecore-x-window-interface.h>
+
+namespace //unnamed namespace
+{
+const char* const CBHM_WINDOW = "CBHM_XWIN";
+const char* const CBHM_MSG = "CBHM_MSG";
+const char* const CBHM_ITEM = "CBHM_ITEM";
+const char* const CBHM_cCOUNT = "CBHM_cCOUNT";
+const char* const CBHM_ERROR = "CBHM_ERROR";
+const char* const SET_ITEM = "SET_ITEM";
+const char* const SHOW = "show0";
+const char* const HIDE = "cbhm_hide";
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Clipboard
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+BaseHandle Create()
+{
+ BaseHandle handle( Clipboard::Get() );
+
+ if ( !handle && Adaptor::IsAvailable() )
+ {
+ Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
+
+ // The Ecore_X_Window needs to use the Clipboard.
+ // Only when the render surface is window, we can get the Ecore_X_Window.
+ Ecore_X_Window ecoreXwin( 0 );
+ Dali::RenderSurface& surface( adaptorImpl.GetSurface() );
+ if( surface.GetType() == Dali::RenderSurface::WINDOW )
+ {
+ ecoreXwin = AnyCast< Ecore_X_Window >( adaptorImpl.GetSurface().GetSurface() );
+ }
+
+ // If we fail to get Ecore_X_Window, we can't use the Clipboard correctly.
+ // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
+ // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
+ Dali::Clipboard clipboard = Dali::Clipboard( new Clipboard( ecoreXwin ) );
+ adaptorImpl.RegisterSingleton( typeid( clipboard ), clipboard );
+ handle = clipboard;
+ }
+
+ return handle;
+}
+TypeRegistration CLIPBOARD_TYPE( typeid(Dali::Clipboard), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
+
+} // unnamed namespace
+
+Clipboard::Clipboard( Ecore_X_Window ecoreXwin)
+{
+ mApplicationWindow = ecoreXwin;
+}
+
+Clipboard::~Clipboard()
+{
+}
+
+Dali::Clipboard Clipboard::Get()
+{
+ Dali::Clipboard clipboard;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::Clipboard ) );
+ if(handle)
+ {
+ // If so, downcast the handle
+ clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
+ }
+ }
+
+ return clipboard;
+}
+bool Clipboard::SetItem(const std::string &itemData )
+{
+ Ecore_X_Window cbhmWin = ECore::WindowInterface::GetWindow();
+ Ecore_X_Atom atomCbhmItem = ecore_x_atom_get( CBHM_ITEM );
+ Ecore_X_Atom dataType = ECORE_X_ATOM_STRING;
+
+ // Set item (property) to send
+ ecore_x_window_prop_property_set( cbhmWin, atomCbhmItem, dataType, 8, const_cast<char*>( itemData.c_str() ), itemData.length() + 1 );
+ ecore_x_sync();
+
+ // Trigger sending of item (property)
+ Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get( CBHM_MSG );
+ ECore::WindowInterface::SendXEvent(ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, SET_ITEM );
+ return true;
+}
+
+/*
+ * Get string at given index of clipboard
+ */
+std::string Clipboard::GetItem( unsigned int index ) // change string to a Dali::Text object.
+{
+ if ( index >= NumberOfItems() )
+ {
+ return "";
+ }
+
+ std::string emptyString( "" );
+ char sendBuf[20];
+
+ snprintf( sendBuf, 20, "%s%d", CBHM_ITEM, index );
+ Ecore_X_Atom xAtomCbhmItem = ecore_x_atom_get( sendBuf );
+ Ecore_X_Atom xAtomItemType = 0;
+
+ std::string clipboardString( ECore::WindowInterface::GetWindowProperty(xAtomCbhmItem, &xAtomItemType, index ) );
+ if ( !clipboardString.empty() )
+ {
+ Ecore_X_Atom xAtomCbhmError = ecore_x_atom_get( CBHM_ERROR );
+ if ( xAtomItemType != xAtomCbhmError )
+ {
+ return clipboardString;
+ }
+ }
+ return emptyString;
+}
+
+/*
+ * Get number of items in clipboard
+ */
+unsigned int Clipboard::NumberOfItems()
+{
+ Ecore_X_Atom xAtomCbhmCountGet = ecore_x_atom_get( CBHM_cCOUNT );
+
+ std::string ret( ECore::WindowInterface::GetWindowProperty( xAtomCbhmCountGet, NULL, 0 ) );
+ int count = -1;
+
+ if ( !ret.empty() )
+ {
+ count = atoi( ret.c_str() );
+ }
+
+ return count;
+}
+
+/**
+ * Show clipboard window
+ * Function to send message to show the Clipboard (cbhm) as no direct API available
+ * Reference elementary/src/modules/ctxpopup_copypasteUI/cbhm_helper.c
+ */
+void Clipboard::ShowClipboard()
+{
+ // Claim the ownership of the SECONDARY selection.
+ ecore_x_selection_secondary_set(mApplicationWindow, "", 1);
+ Ecore_X_Window cbhmWin = ECore::WindowInterface::GetWindow();
+
+ // Launch the clipboard window
+ Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get( CBHM_MSG );
+ ECore::WindowInterface::SendXEvent( ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, SHOW );
+}
+
+void Clipboard::HideClipboard()
+{
+ Ecore_X_Window cbhmWin = ECore::WindowInterface::GetWindow();
+ // Launch the clipboard window
+ Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get( CBHM_MSG );
+ ECore::WindowInterface::SendXEvent( ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, HIDE );
+
+ // release the ownership of SECONDARY selection
+ ecore_x_selection_secondary_clear();
+}
+
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_CLIPBOARD_H__
+#define __DALI_INTERNAL_CLIPBOARD_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <clipboard.h>
+#include <dali/public-api/object/base-object.h>
+#include <Ecore_X.h>
+
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Implementation of the Clip Board
+ */
+
+class Clipboard : public Dali::BaseObject
+{
+public:
+
+ /**
+ * @copydoc Dali::ClipboardEventNotifier::Get()
+ */
+ static Dali::Clipboard Get();
+
+ /**
+ * Constructor
+ * @param[in] ecoreXwin, The window is created by application.
+ */
+ Clipboard(Ecore_X_Window ecoreXwin);
+
+ virtual ~Clipboard();
+
+ /**
+ * @copydoc Dali::Clipboard::SetItem()
+ */
+ bool SetItem(const std::string &itemData);
+
+ /**
+ * @copydoc Dali::Clipboard::GetItem()
+ */
+ std::string GetItem( unsigned int index );
+
+ /**
+ * @copydoc Dali::Clipboard::NumberOfClipboardItems()
+ */
+ unsigned int NumberOfItems();
+
+ /**
+ * @copydoc Dali::Clipboard::ShowClipboard()
+ */
+ void ShowClipboard();
+
+ /**
+ * @copydoc Dali::Clipboard::HideClipboard()
+ */
+ void HideClipboard();
+
+
+private:
+ Ecore_X_Window mApplicationWindow;
+ Clipboard( const Clipboard& );
+ Clipboard& operator=( Clipboard& );
+
+}; // class clipboard
+
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+ inline static Internal::Adaptor::Clipboard& GetImplementation(Dali::Clipboard& clipboard)
+ {
+ DALI_ASSERT_ALWAYS( clipboard && "Clipboard handle is empty" );
+ BaseObject& handle = clipboard.GetBaseObject();
+ return static_cast<Internal::Adaptor::Clipboard&>(handle);
+ }
+
+ inline static const Internal::Adaptor::Clipboard& GetImplementation(const Dali::Clipboard& clipboard)
+ {
+ DALI_ASSERT_ALWAYS( clipboard && "Clipboard handle is empty" );
+ const BaseObject& handle = clipboard.GetBaseObject();
+ return static_cast<const Internal::Adaptor::Clipboard&>(handle);
+ }
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_CLIPBOARD_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "pixmap-render-surface.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECore
+{
+
+DALI_EXPORT_API RenderSurface* CreatePixmapSurface(
+ PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent )
+{
+ return new PixmapRenderSurface( positionSize, surface, display, name, isTransparent );
+}
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+
+
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_ECORE_X_RENDER_SURFACE_FACTORY_H__
+#define __DALI_INTERNAL_ADAPTOR_ECORE_X_RENDER_SURFACE_FACTORY_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <boost/any.hpp>
+#include <string>
+#include <dali/public-api/math/rect.h>
+#include <dali/public-api/common/dali-common.h>
+
+// INTERNAL INCLUDES
+#include <native-buffer-pool.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECore
+{
+
+class RenderSurface;
+
+/**
+ * Surface factory function for pixmap
+ * A pixmap surface is created.
+ *
+ * @param [in] type the type of surface to create
+ * @param [in] positionSize the position and size of the surface to create
+ * @param [in] display X Pixmap to use, or null for default.
+ * @param [in] display X Display to use, or null for default.
+ * @param [in] name Name of surface passed in
+ * @param [in] isTransparent Whether the surface has an alpha channel
+ */
+DALI_IMPORT_API RenderSurface* CreatePixmapSurface(
+ PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent );
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ADAPTOR_ECORE_X_RENDER_SURFACE_FACTORY_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "ecore-x-render-surface.h"
+
+// EXTERNAL INCLUDES
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <X11/extensions/Xfixes.h> // for damage notify
+#include <X11/extensions/Xdamage.h> // for damage notify
+
+#include <dali/integration-api/gl-abstraction.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <ecore-x-types.h>
+#include <trigger-event.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_ECORE_X_RENDER_SURFACE");
+#endif
+
+namespace ECore
+{
+
+namespace
+{
+
+const float MINIMUM_DIMENSION_CHANGE = 1.0f; ///< Minimum change for window to be considered to have moved
+static bool gXInitThreadsCalled = false; ///< global to say whether XInitThreads has been called in this process
+const unsigned int MICROSECONDS_PER_SECOND = 1000000;
+const unsigned int MILLISECONDS_PER_SECOND = 1000;
+
+} // unnamed namespace
+
+RenderSurface::RenderSurface( SurfaceType type,
+ Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent)
+: mMainDisplay(NULL),
+ mType(type),
+ mPosition(positionSize),
+ mTitle(name),
+ mColorDepth(isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24),
+ mRenderMode((type == PIXMAP) ? RENDER_SYNC : RENDER_DEFAULT),
+ mRenderNotification( NULL ),
+ mSyncMode(SYNC_MODE_NONE),
+ mSyncReceived( false ),
+ mOwnSurface(false),
+ mOwnDisplay(false),
+ mIsStopped( false )
+{
+ // see if there is a display in Any display
+ SetDisplay( display );
+}
+
+void RenderSurface::Init( Any surface )
+{
+ // see if there is a surface in Any surface
+ unsigned int surfaceId = GetSurfaceId( surface );
+
+ // if the surface is empty, create a new one.
+ if ( surfaceId == 0 )
+ {
+ // make sure XInitThreads is called
+ if ( !gXInitThreadsCalled )
+ {
+ XInitThreads();
+ gXInitThreadsCalled = true;
+ }
+
+ // we own the surface about to created
+ mOwnSurface = true;
+ CreateXRenderable();
+ }
+ else
+ {
+ // XLib should already be initialized so no point in calling XInitThreads
+ UseExistingRenderable( surfaceId );
+ }
+
+#ifdef DEBUG_ENABLED
+ // prints out 'INFO: DALI: new RenderSurface, created display xx, used existing surface xx
+ // we can not use LOG_INFO because the surface can be created before Dali Core is created.
+ printf( "INFO: DALI: new RenderSurface, %s display %p, %s %s surface %X \n",
+ mOwnDisplay?"created":"used existing",mMainDisplay,
+ mOwnSurface?"created":"used existing",
+ Dali::RenderSurface::PIXMAP==mType?" pixmap" :"window",
+ GetDrawable() );
+#endif
+}
+
+RenderSurface::~RenderSurface()
+{
+ // release the display connection if we use our own
+ if( mOwnDisplay )
+ {
+ if( mMainDisplay )
+ {
+ // NOTE, on 64bit desktop with some NVidia driver versions this crashes
+#ifdef _ARCH_ARM_
+ XCloseDisplay( mMainDisplay );
+#endif
+ }
+ }
+}
+
+Ecore_X_Window RenderSurface::GetXWindow()
+{
+ return 0;
+}
+
+XDisplay* RenderSurface::GetMainDisplay()
+{
+ return mMainDisplay;
+}
+
+void RenderSurface::SetRenderNotification( TriggerEvent* renderNotification )
+{
+ mRenderNotification = renderNotification;
+}
+
+Ecore_X_Drawable RenderSurface::GetDrawable()
+{
+ return 0;
+}
+
+Any RenderSurface::GetDisplay()
+{
+ // this getter is used by main thread so we need to return the main thread version of the display
+ return Any( ecore_x_display_get() );
+}
+
+PositionSize RenderSurface::GetPositionSize() const
+{
+ return mPosition;
+}
+
+void RenderSurface::SetRenderMode(RenderMode mode)
+{
+ mRenderMode = mode;
+}
+
+Dali::RenderSurface::RenderMode RenderSurface::GetRenderMode() const
+{
+ return mRenderMode;
+}
+
+void RenderSurface::MoveResize( Dali::PositionSize positionSize )
+{
+ // nothing to do in base class
+}
+
+void RenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) const
+{
+ // calculate DPI
+ float xres, yres;
+
+ // 1 inch = 25.4 millimeters
+ xres = ecore_x_dpi_get();
+ yres = ecore_x_dpi_get();
+
+ dpiHorizontal = int(xres + 0.5f); // rounding
+ dpiVertical = int(yres + 0.5f);
+}
+
+void RenderSurface::Map()
+{
+}
+
+void RenderSurface::TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface )
+{
+ // if we don't own the display return
+ if( mOwnDisplay == false )
+ {
+ return;
+ }
+
+ RenderSurface* other = dynamic_cast< RenderSurface* >( &newSurface );
+ if( other )
+ {
+ // if both surfaces share the same display, and this surface owns it,
+ // then transfer the ownership to the new surface
+ if( other->mMainDisplay == mMainDisplay )
+ {
+ mOwnDisplay = false;
+ other->mOwnDisplay = true;
+ }
+ }
+}
+
+void RenderSurface::ConsumeEvents()
+{
+ // if the render surface has own display, check events so that we can flush the queue and avoid
+ // any potential memory leaks in X
+ if( mOwnDisplay )
+ {
+ // looping if events remain
+ int events( 0 );
+ do
+ {
+ // Check if there are any events in the queue
+ events = XEventsQueued( mMainDisplay, QueuedAfterFlush );
+
+ if ( events > 0 )
+ {
+ // Just flush event to prevent memory leak from event queue as the events get built up in
+ // memory but are only deleted when we retrieve them
+ XEvent ev;
+ XNextEvent( mMainDisplay, &ev );
+ }
+ }
+ while( events > 0 );
+ }
+}
+
+void RenderSurface::StopRender()
+{
+ // Stop blocking waiting for sync
+ SetSyncMode( RenderSurface::SYNC_MODE_NONE );
+ // Simulate a RenderSync in case render-thread is currently blocked
+ RenderSync();
+
+ mIsStopped = true;
+}
+
+void RenderSurface::SetViewMode( ViewMode )
+{
+}
+
+void RenderSurface::SetDisplay( Any display )
+{
+ // the render surface can be passed either EFL e-core types, or x11 types
+ // we use boost any to determine at run time which type
+
+ if ( display.Empty() == false )
+ {
+ // check we have a valid type
+ DALI_ASSERT_ALWAYS( ( ( display.GetType() == typeid (Ecore_X_Display *)) ||
+ ( display.GetType() == typeid (XDisplay *) ) )
+ &&
+ "Display type is invalid" );
+
+ mOwnDisplay = false;
+
+ // display may point to EcoreXDisplay so may need to cast
+ if( display.GetType() == typeid (Ecore_X_Display*) )
+ {
+ mMainDisplay = static_cast< XDisplay* >( AnyCast< Ecore_X_Display* >( display ) );
+ }
+ else
+ {
+ mMainDisplay = AnyCast< XDisplay* >( display );
+ }
+ }
+ else
+ {
+ mOwnDisplay = true;
+ // mMainDisplay = (XDisplay*)ecore_x_display_get();
+ // Because of DDK issue, we need to use separated x display instead of ecore default display
+ mMainDisplay = XOpenDisplay(0);
+ }
+}
+
+unsigned int RenderSurface::GetSurfaceId( Any surface ) const
+{
+ unsigned int surfaceId = 0;
+
+ if ( surface.Empty() == false )
+ {
+ // check we have a valid type
+ DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (XWindow) ) ||
+ (surface.GetType() == typeid (Ecore_X_Window) ) )
+ && "Surface type is invalid" );
+
+ if ( surface.GetType() == typeid (Ecore_X_Window) )
+ {
+ surfaceId = AnyCast<Ecore_X_Window>( surface );
+ }
+ else
+ {
+ surfaceId = AnyCast<XWindow>( surface );
+ }
+ }
+ return surfaceId;
+}
+
+void RenderSurface::RenderSync()
+{
+ // nothing to do
+}
+
+void RenderSurface::DoRenderSync( unsigned int timeDelta, SyncMode syncMode )
+{
+ // Should block waiting for RenderSync?
+ if( mRenderMode == Dali::RenderSurface::RENDER_SYNC )
+ {
+ boost::unique_lock< boost::mutex > lock( mSyncMutex );
+
+ // wait for sync
+ if( syncMode != SYNC_MODE_NONE &&
+ mSyncMode != SYNC_MODE_NONE &&
+ !mSyncReceived )
+ {
+ mSyncNotify.wait( lock );
+ }
+ mSyncReceived = false;
+ }
+ // Software sync based on a timed delay?
+ else if( mRenderMode > Dali::RenderSurface::RENDER_SYNC )
+ {
+ unsigned int syncPeriod( MICROSECONDS_PER_SECOND / static_cast< unsigned int >( mRenderMode ) - MILLISECONDS_PER_SECOND );
+ if( timeDelta < syncPeriod )
+ {
+ usleep( syncPeriod - timeDelta );
+ }
+ }
+}
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H__
+#define __DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <boost/thread.hpp>
+#include <Ecore_X.h>
+#include <dali/public-api/common/dali-common.h>
+
+// INTERNAL INCLUDES
+#include <render-surface-impl.h>
+#include <ecore-x-types.h>
+#include <gl/egl-implementation.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class TriggerEvent;
+
+namespace ECore
+{
+
+/**
+ * Ecore X11 implementation of render surface.
+ * @todo change namespace to ECore_X11 as the class
+ * is no longer pure X11.
+ */
+class DALI_IMPORT_API RenderSurface : public Internal::Adaptor::RenderSurface
+{
+public:
+ /**
+ * Uses an X11 surface to render to.
+ * @param [in] type the type of surface passed in
+ * @param [in] positionSize the position and size of the surface
+ * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
+ * @param [in] display connection to X-server if the surface is a X window or pixmap (type must be void * to X display struct)
+ * @param [in] name optional name of surface passed in
+ * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
+ */
+ RenderSurface( SurfaceType type,
+ Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent = false);
+
+ /**
+ * Destructor.
+ * Will delete the display, if it has ownership.
+ * Will delete the window/pixmap if it has owner ship
+ */
+ virtual ~RenderSurface();
+
+protected:
+ /**
+ * Second stage construction
+ * Creates the surface (window, pixmap or native buffer)
+ */
+ void Init( Any surface );
+
+public: // API
+
+ /**
+ * @return the Ecore X window handle
+ */
+ Ecore_X_Window GetXWindow();
+
+ /**
+ * @return the Main X display
+ */
+ XDisplay* GetMainDisplay();
+
+ /**
+ * Sets the render notification trigger to call when render thread is completed a frame
+ * @param renderNotification to use
+ */
+ void SetRenderNotification( TriggerEvent* renderNotification );
+
+ /**
+ * Get the surface as an Ecore_X_drawable
+ */
+ virtual Ecore_X_Drawable GetDrawable();
+
+public: // from Dali::RenderSurface
+
+ /**
+ * @copydoc Dali::RenderSurface::GetType()
+ */
+ virtual Dali::RenderSurface::SurfaceType GetType() = 0;
+
+ /**
+ * @copydoc Dali::RenderSurface::GetSurface()
+ */
+ virtual Any GetSurface() = 0;
+
+ /**
+ * @copydoc Dali::RenderSurface::GetDisplay()
+ */
+ virtual Any GetDisplay();
+
+ /**
+ * @copydoc Dali::RenderSurface::GetPositionSize()
+ */
+ virtual PositionSize GetPositionSize() const;
+
+ /**
+ * @copydoc Dali::RenderSurface::SetRenderMode()
+ */
+ virtual void SetRenderMode(RenderMode mode);
+
+ /**
+ * @copydoc Dali::RenderSurface::GetRenderMode()
+ */
+ virtual RenderMode GetRenderMode() const;
+
+public: // from Internal::Adaptor::RenderSurface
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface()
+ */
+ virtual void CreateEglSurface( EglInterface& egl ) = 0;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface()
+ */
+ virtual void DestroyEglSurface( EglInterface& egl ) = 0;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface()
+ */
+ virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::MoveResize()
+ */
+ virtual void MoveResize( Dali::PositionSize positionSize);
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::GetDpi()
+ */
+ virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) const;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::Map()
+ */
+ virtual void Map();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::TransferDisplayOwner()
+ */
+ virtual void TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::ConsumeEvents()
+ */
+ virtual void ConsumeEvents();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::RenderSync()
+ */
+ virtual void RenderSync();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::SetViewMode()
+ */
+ void SetViewMode( ViewMode );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::PreRender()
+ */
+ virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) = 0;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::PostRender()
+ */
+ virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode ) = 0;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::StopRender()
+ */
+ virtual void StopRender();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::SetSyncMode()
+ */
+ virtual void SetSyncMode( SyncMode syncMode ) { mSyncMode = syncMode; }
+
+private:
+
+ /**
+ * Sets the display, if display parameter is empty it opens a new display
+ * @param display
+ */
+ void SetDisplay( Any display );
+
+ /**
+ * Get the surface id if the surface parameter is not empty
+ * @param surface Any containing a surface id, or can be empty
+ * @return surface id, or zero if surface is empty
+ */
+ unsigned int GetSurfaceId( Any surface ) const;
+
+protected:
+
+ /**
+ * Create XRenderable
+ */
+ virtual void CreateXRenderable() = 0;
+
+ /**
+ * Use an existing render surface
+ * @param surfaceId the id of the surface
+ */
+ virtual void UseExistingRenderable( unsigned int surfaceId ) = 0;
+
+ /**
+ * Perform render sync
+ * @param[in] currentTime Current time in microseconds
+ * @param[in] syncMode Wait for RenderSync (from Adaptor) flag. A member of SyncMode
+ */
+ void DoRenderSync( unsigned int timeDelta, SyncMode syncMode );
+
+protected: // Data
+
+ XDisplay* mMainDisplay; ///< X-connection for rendering
+ Ecore_X_Window mRootWindow; ///< X-Root window
+ SurfaceType mType; ///< type of renderable
+ PositionSize mPosition; ///< Position
+ std::string mTitle; ///< Title of window which shows from "xinfo -topvwins" command
+ ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
+ RenderMode mRenderMode; ///< Render mode for pixmap surface type
+ TriggerEvent* mRenderNotification; ///< Render notificatin trigger
+ boost::mutex mSyncMutex; ///< mutex to lock during waiting sync
+ boost::condition_variable mSyncNotify; ///< condition to notify main thread that pixmap was flushed to onscreen
+ SyncMode mSyncMode;
+ bool mSyncReceived; ///< true, when a pixmap sync has occurred, (cleared after reading)
+ bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
+ bool mOwnDisplay; ///< Whether we own the display (responsible for deleting it)
+ bool mIsStopped; ///< Render should be stopped
+};
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H__
--- /dev/null
+#ifndef __DALI_INTERNAL_X11_TYPES_H__
+#define __DALI_INTERNAL_X11_TYPES_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <X11/Xlib.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+typedef ::Pixmap XPixmap;
+typedef ::Window XWindow;
+typedef ::Display XDisplay;
+typedef ::Screen XScreen;
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif /* __DALI_INTERNAL_X11_TYPES_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "ecore-x-window-interface.h"
+
+// EXTERNAL INCLUDES
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <ecore-x-types.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECore
+{
+
+namespace WindowInterface
+{
+// CONSTANTS
+const char* const CBHM_WINDOW = "CBHM_XWIN";
+
+Ecore_X_Window GetWindow()
+{
+ Ecore_X_Atom xAtomCbhm = ecore_x_atom_get( CBHM_WINDOW );
+
+ Ecore_X_Window xCbhmWin = 0;
+ unsigned char *buf = NULL;
+ int num = 0;
+ int ret = ecore_x_window_prop_property_get( 0, xAtomCbhm, XA_WINDOW, 0, &buf, &num );
+
+ if ( ret && num )
+ {
+ memcpy( &xCbhmWin, buf, sizeof( Ecore_X_Window ) );
+ }
+ if ( buf )
+ {
+ free( buf );
+ }
+
+ return xCbhmWin;
+}
+
+std::string GetWindowProperty( Ecore_X_Atom property, Ecore_X_Atom *xDataType, unsigned int num )
+{
+ std::string data("");
+
+ if ( !property )
+ {
+ return data;
+ }
+
+ ecore_x_sync();
+
+ long unsigned int numRet = 0, bytes = 0;
+ int ret = 0, sizeRet;
+ unsigned int i;
+ unsigned char *propRet;
+ Ecore_X_Atom typeRet;
+
+ // X11 Function to get window property
+ ret = XGetWindowProperty( static_cast<Display*>(ecore_x_display_get()), // Display* X Server Connection
+ GetWindow(), // Window window in question
+ property, // Atom name of property
+ num, // long offset where required data is stored
+ LONG_MAX, // long length of data to retrieve
+ False, // Bool flag to delete data
+ ecore_x_window_prop_any_type(), // Atom atom id associated to property type
+ (Atom *)&typeRet, // Atom actual_type_return, atom id property type
+ &sizeRet, // int* format of property
+ &numRet, // unsigned long* number of items being returned in prop_return
+ &bytes, // unsigned long* remaining bytes if partial retrieval
+ &propRet ); // unsigned char** return data
+ if ( ret != Success )
+ {
+ return data;
+ }
+
+ if ( !numRet )
+ {
+ XFree( propRet );
+ return data;
+ }
+
+ numRet--; // As propRet in XGetWindowProperty gets an extra 0 added for compatibility reasons.
+
+ switch ( sizeRet ) // Format returned by XGetWindowProperty int, short, long
+ {
+ case 8:
+ {
+ for ( i = 0; i < numRet; i++ )
+ {
+ data += propRet[i];
+ }
+ }
+ break;
+
+ case 16:
+ {
+ for ( i = 0; i < numRet; i++ )
+ {
+ data += ( ( unsigned short * )propRet )[i];
+ }
+ }
+ break;
+
+ case 32:
+ {
+ for ( i = 0; i < numRet; i++ )
+ {
+ data += ( ( unsigned long * )propRet )[i];
+ }
+ }
+ break;
+ }
+
+ XFree( propRet );
+
+ if ( xDataType )
+ {
+ *xDataType = typeRet;
+ }
+
+ return data;
+ }
+
+void SendXEvent(Ecore_X_Display* display, Ecore_X_Window window, bool propagate,
+ long int eventMask, Ecore_X_Atom messageType, int messageFormat, const char *msg )
+{
+ XClientMessageEvent message;
+ memset(&message, 0, sizeof( message ) );
+ message.type = ClientMessage;
+ message.display = static_cast<Display*>( display );
+ message.message_type = messageType;
+ message.format = messageFormat;
+ message.window = window;
+ snprintf(message.data.b, 20, "%s", msg);
+
+ XSendEvent( static_cast<Display*>( display ), window, propagate, eventMask,( XEvent* )&message );
+}
+
+
+} // namespace WindowInterface
+
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H__
+#define __DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+#include <Ecore_X.h>
+#include <X11/Xlib.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECore
+{
+
+namespace WindowInterface
+{
+/**
+ * X11 Window interface, to separate X11 calls within adaptor.
+ */
+
+/**
+ * Gets the Ecore X Window
+ * @return window
+ */
+ Ecore_X_Window GetWindow();
+
+ /**
+ * Gets a specified X window property
+ * @param[in] property the required property id
+ * @param[in] xDataType the type
+ * @param[in] num the offset / index of the property
+ * @return string the property value
+ */
+ std::string GetWindowProperty( Ecore_X_Atom property, Ecore_X_Atom *xDataType, unsigned int num );
+
+ /**
+ * Send an X Event
+ * @param[in] display target display
+ * @param[in] window target window
+ * @param[in] propagate to propagate to other windows
+ * @parma[in] eventMask event mask
+ * @param[in] messageType Ecore_X_Atom message type
+ * @param[in] messageFormat format of message
+ * @param[in] msg message to send
+ */
+ void SendXEvent(Ecore_X_Display* display, Ecore_X_Window window, bool propagate,
+ long int eventMask, Ecore_X_Atom messageType, int messageFormat, const char *msg );
+
+} // namespace WindowInterface
+
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+// CLASS HEADER
+#include <gl/egl-implementation.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/dali-vector.h>
+
+// INTERNAL INCLUDES
+#include <ecore-x-render-surface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+#define TEST_EGL_ERROR(lastCommand) \
+{ \
+ EGLint err = eglGetError(); \
+ if (err != EGL_SUCCESS) \
+ { \
+ DALI_LOG_ERROR("EGL error after %s code=%d\n", lastCommand,err); \
+ DALI_ASSERT_ALWAYS(0 && "EGL error"); \
+ } \
+}
+
+EglImplementation::EglImplementation()
+ : mEglNativeDisplay(0),
+ mEglNativeWindow(0),
+ mEglNativePixmap(0),
+ mEglDisplay(0),
+ mEglConfig(0),
+ mEglContext(0),
+ mEglSurface(0),
+ mGlesInitialized(false),
+ mIsOwnSurface(true),
+ mSyncMode(FULL_SYNC),
+ mContextCurrent(false),
+ mIsWindow(true),
+ mColorDepth(COLOR_DEPTH_24)
+{
+}
+
+EglImplementation::~EglImplementation()
+{
+ TerminateGles();
+}
+
+bool EglImplementation::InitializeGles( EGLNativeDisplayType display, bool isOwnSurface )
+{
+ if ( !mGlesInitialized )
+ {
+ mEglNativeDisplay = display;
+
+ //@todo see if we can just EGL_DEFAULT_DISPLAY instead
+ mEglDisplay = eglGetDisplay(mEglNativeDisplay);
+
+ EGLint majorVersion = 0;
+ EGLint minorVersion = 0;
+ if ( !eglInitialize( mEglDisplay, &majorVersion, &minorVersion ) )
+ {
+ return false;
+ }
+ eglBindAPI(EGL_OPENGL_ES_API);
+
+ mContextAttribs.Clear();
+
+#if DALI_GLES_VERSION >= 30
+
+ mContextAttribs.Reserve(5);
+ mContextAttribs.PushBack( EGL_CONTEXT_MAJOR_VERSION_KHR );
+ mContextAttribs.PushBack( 3 );
+ mContextAttribs.PushBack( EGL_CONTEXT_MINOR_VERSION_KHR );
+ mContextAttribs.PushBack( 0 );
+
+#else // DALI_GLES_VERSION >= 30
+
+ mContextAttribs.Reserve(3);
+ mContextAttribs.PushBack( EGL_CONTEXT_CLIENT_VERSION );
+ mContextAttribs.PushBack( 2 );
+
+#endif // DALI_GLES_VERSION >= 30
+
+ mContextAttribs.PushBack( EGL_NONE );
+
+ mGlesInitialized = true;
+ mIsOwnSurface = isOwnSurface;
+ }
+
+ return mGlesInitialized;
+}
+
+bool EglImplementation::CreateContext()
+{
+ // make sure a context isn't created twice
+ DALI_ASSERT_ALWAYS( (mEglContext == 0) && "EGL context recreated" );
+
+ mEglContext = eglCreateContext(mEglDisplay, mEglConfig, NULL, &(mContextAttribs[0]));
+ TEST_EGL_ERROR("eglCreateContext render thread");
+
+ DALI_ASSERT_ALWAYS( EGL_NO_CONTEXT != mEglContext && "EGL context not created" );
+
+ return true;
+}
+
+void EglImplementation::DestroyContext()
+{
+ DALI_ASSERT_ALWAYS( mEglContext && "no EGL context" );
+
+ eglDestroyContext( mEglDisplay, mEglContext );
+ mEglContext = 0;
+}
+
+void EglImplementation::DestroySurface()
+{
+ if(mIsOwnSurface && mEglSurface)
+ {
+ eglDestroySurface( mEglDisplay, mEglSurface );
+ mEglSurface = 0;
+ }
+}
+
+void EglImplementation::MakeContextCurrent()
+{
+ mContextCurrent = true;
+
+ if(mIsOwnSurface)
+ {
+ eglMakeCurrent( mEglDisplay, mEglSurface, mEglSurface, mEglContext );
+ }
+
+ EGLint error = eglGetError();
+
+ if ( error != EGL_SUCCESS )
+ {
+ switch (error)
+ {
+ case EGL_BAD_DISPLAY:
+ {
+ DALI_LOG_ERROR("EGL_BAD_DISPLAY : Display is not an EGL display connection");
+ break;
+ }
+ case EGL_NOT_INITIALIZED:
+ {
+ DALI_LOG_ERROR("EGL_NOT_INITIALIZED : Display has not been initialized");
+ break;
+ }
+ case EGL_BAD_SURFACE:
+ {
+ DALI_LOG_ERROR("EGL_BAD_SURFACE : Draw or read is not an EGL surface");
+ break;
+ }
+ case EGL_BAD_CONTEXT:
+ {
+ DALI_LOG_ERROR("EGL_BAD_CONTEXT : Context is not an EGL rendering context");
+ break;
+ }
+ case EGL_BAD_MATCH:
+ {
+ DALI_LOG_ERROR("EGL_BAD_MATCH : Draw or read are not compatible with context, or if context is set to EGL_NO_CONTEXT and draw or read are not set to EGL_NO_SURFACE, or if draw or read are set to EGL_NO_SURFACE and context is not set to EGL_NO_CONTEXT");
+ break;
+ }
+ case EGL_BAD_ACCESS:
+ {
+ DALI_LOG_ERROR("EGL_BAD_ACCESS : Context is current to some other thread");
+ break;
+ }
+ case EGL_BAD_NATIVE_PIXMAP:
+ {
+ DALI_LOG_ERROR("EGL_BAD_NATIVE_PIXMAP : A native pixmap underlying either draw or read is no longer valid.");
+ break;
+ }
+ case EGL_BAD_NATIVE_WINDOW:
+ {
+ DALI_LOG_ERROR("EGL_BAD_NATIVE_WINDOW : A native window underlying either draw or read is no longer valid.");
+ break;
+ }
+ case EGL_BAD_CURRENT_SURFACE:
+ {
+ DALI_LOG_ERROR("EGL_BAD_CURRENT_SURFACE : The previous context has unflushed commands and the previous surface is no longer valid.");
+ break;
+ }
+ case EGL_BAD_ALLOC:
+ {
+ DALI_LOG_ERROR("EGL_BAD_ALLOC : Allocation of ancillary buffers for draw or read were delayed until eglMakeCurrent is called, and there are not enough resources to allocate them");
+ break;
+ }
+ case EGL_CONTEXT_LOST:
+ {
+ DALI_LOG_ERROR("EGL_CONTEXT_LOST : If a power management event has occurred. The application must destroy all contexts and reinitialise OpenGL ES state and objects to continue rendering");
+ break;
+ }
+ default:
+ {
+ DALI_LOG_ERROR("Unknown error");
+ break;
+ }
+ }
+ DALI_ASSERT_ALWAYS(false && "MakeContextCurrent failed!");
+ }
+
+ // We want to display this information all the time, so use the LogMessage directly
+ Integration::Log::LogMessage(Integration::Log::DebugInfo, "EGL Information\n"
+ " Vendor: %s\n"
+ " Version: %s\n"
+ " Client APIs: %s\n"
+ " Extensions: %s\n",
+ eglQueryString(mEglDisplay, EGL_VENDOR),
+ eglQueryString(mEglDisplay, EGL_VERSION),
+ eglQueryString(mEglDisplay, EGL_CLIENT_APIS),
+ eglQueryString(mEglDisplay, EGL_EXTENSIONS));
+
+ if ( mIsWindow )
+ {
+ SetRefreshSync( mSyncMode );
+ }
+}
+
+void EglImplementation::MakeContextNull()
+{
+ mContextCurrent = false;
+ // clear the current context
+ eglMakeCurrent( mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
+}
+
+void EglImplementation::TerminateGles()
+{
+ if ( mGlesInitialized )
+ {
+ // in latest Mali DDK (r2p3 ~ r3p0 in April, 2012),
+ // MakeContextNull should be called before eglDestroy surface
+ // to prevent crash in _mali_surface_destroy_callback
+ MakeContextNull();
+
+ if(mIsOwnSurface && mEglSurface)
+ {
+ eglDestroySurface(mEglDisplay, mEglSurface);
+ }
+ eglDestroyContext(mEglDisplay, mEglContext);
+
+ eglTerminate(mEglDisplay);
+
+ mEglDisplay = NULL;
+ mEglConfig = NULL;
+ mEglContext = NULL;
+ mEglSurface = NULL;
+
+ mGlesInitialized = false;
+ }
+}
+
+bool EglImplementation::IsGlesInitialized() const
+{
+ return mGlesInitialized;
+}
+
+bool EglImplementation::SetRefreshSync( SyncMode mode )
+{
+ if ( mIsWindow == false )
+ {
+ return false;
+ }
+ mSyncMode = mode;
+
+ // eglSwapInterval specifies the minimum number of video frame periods
+ // per buffer swap for the window associated with the current context.
+
+ if ( !mContextCurrent )
+ {
+ return true;
+ }
+
+ EGLBoolean ok = eglSwapInterval( mEglDisplay, mode );
+ if ( !ok )
+ {
+ TEST_EGL_ERROR("eglSwapInterval");
+ return false;
+ }
+
+ return true;
+}
+
+void EglImplementation::SwapBuffers()
+{
+ eglSwapBuffers( mEglDisplay, mEglSurface );
+}
+
+void EglImplementation::CopyBuffers()
+{
+ eglCopyBuffers( mEglDisplay, mEglSurface, mEglNativePixmap );
+}
+
+void EglImplementation::WaitGL()
+{
+ eglWaitGL();
+}
+
+void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
+{
+ if(mEglConfig && isWindowType == mIsWindow && mColorDepth == depth)
+ {
+ return;
+ }
+
+ mIsWindow = isWindowType;
+
+ EGLint numConfigs;
+ Vector<EGLint> configAttribs;
+ configAttribs.Reserve(31);
+
+ if(isWindowType)
+ {
+ configAttribs.PushBack( EGL_SURFACE_TYPE );
+ configAttribs.PushBack( EGL_WINDOW_BIT );
+ }
+ else
+ {
+ configAttribs.PushBack( EGL_SURFACE_TYPE );
+ configAttribs.PushBack( EGL_PIXMAP_BIT );
+ }
+
+ configAttribs.PushBack( EGL_RENDERABLE_TYPE );
+
+#if DALI_GLES_VERSION >= 30
+
+#ifdef _ARCH_ARM_
+ configAttribs.PushBack( EGL_OPENGL_ES3_BIT_KHR );
+#else
+ // There is a bug in the desktop emulator
+ // Requesting for ES3 causes eglCreateContext even though it allows to ask
+ // for a configuration that supports GLES 3.0
+ configAttribs.PushBack( EGL_OPENGL_ES2_BIT );
+#endif // _ARCH_ARM_
+
+#else // DALI_GLES_VERSION >= 30
+
+ configAttribs.PushBack( EGL_OPENGL_ES2_BIT );
+
+#endif //DALI_GLES_VERSION >= 30
+
+#if DALI_GLES_VERSION >= 30
+// TODO: enable this flag when it becomes supported
+// configAttribs.PushBack( EGL_CONTEXT_FLAGS_KHR );
+// configAttribs.PushBack( EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR );
+#endif //DALI_GLES_VERSION >= 30
+
+ configAttribs.PushBack( EGL_RED_SIZE );
+ configAttribs.PushBack( 8 );
+ configAttribs.PushBack( EGL_GREEN_SIZE );
+ configAttribs.PushBack( 8 );
+ configAttribs.PushBack( EGL_BLUE_SIZE );
+ configAttribs.PushBack( 8 );
+
+ configAttribs.PushBack( EGL_ALPHA_SIZE );
+#ifdef _ARCH_ARM_
+ configAttribs.PushBack( (depth == COLOR_DEPTH_32) ? 8 : 0 );
+#else
+ // There is a bug in the desktop emulator
+ // setting EGL_ALPHA_SIZE to 8 results in eglChooseConfig failing
+ configAttribs.PushBack( 0 );
+#endif // _ARCH_ARM_
+
+ configAttribs.PushBack( EGL_DEPTH_SIZE );
+ configAttribs.PushBack( 24 );
+ configAttribs.PushBack( EGL_STENCIL_SIZE );
+ configAttribs.PushBack( 8 );
+ configAttribs.PushBack( EGL_SAMPLES );
+ configAttribs.PushBack( 4 );
+ configAttribs.PushBack( EGL_SAMPLE_BUFFERS );
+ configAttribs.PushBack( 1 );
+ configAttribs.PushBack( EGL_NONE );
+
+ if ( eglChooseConfig( mEglDisplay, &(configAttribs[0]), &mEglConfig, 1, &numConfigs ) != EGL_TRUE )
+ {
+ EGLint error = eglGetError();
+ switch (error)
+ {
+ case EGL_BAD_DISPLAY:
+ {
+ DALI_LOG_ERROR("Display is not an EGL display connection");
+ break;
+ }
+ case EGL_BAD_ATTRIBUTE:
+ {
+ DALI_LOG_ERROR("The parameter confirAttribs contains an invalid frame buffer configuration attribute or an attribute value that is unrecognized or out of range");
+ break;
+ }
+ case EGL_NOT_INITIALIZED:
+ {
+ DALI_LOG_ERROR("Display has not been initialized");
+ break;
+ }
+ case EGL_BAD_PARAMETER:
+ {
+ DALI_LOG_ERROR("The parameter numConfig is NULL");
+ break;
+ }
+ default:
+ {
+ DALI_LOG_ERROR("Unknown error");
+ }
+ }
+ DALI_ASSERT_ALWAYS(false && "eglChooseConfig failed!");
+ }
+
+ if ( numConfigs != 1 )
+ {
+ DALI_LOG_ERROR("No configurations found.");
+
+ TEST_EGL_ERROR("eglChooseConfig");
+ }
+}
+
+
+void EglImplementation::CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth )
+{
+ DALI_ASSERT_ALWAYS( ( mEglSurface == 0 ) && "EGL surface already exists" );
+
+ mEglNativeWindow = window;
+ mColorDepth = depth;
+ mIsWindow = true;
+
+ // egl choose config
+ ChooseConfig(mIsWindow, mColorDepth);
+
+ mEglSurface = eglCreateWindowSurface( mEglDisplay, mEglConfig, mEglNativeWindow, NULL );
+ TEST_EGL_ERROR("eglCreateWindowSurface");
+
+ DALI_ASSERT_ALWAYS( mEglSurface && "Create window surface failed" );
+}
+
+void EglImplementation::CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth )
+{
+ DALI_ASSERT_ALWAYS( mEglSurface == 0 && "Cannot create more than one instance of surface pixmap" );
+
+ mEglNativePixmap = pixmap;
+ mColorDepth = depth;
+ mIsWindow = false;
+
+ // egl choose config
+ ChooseConfig(mIsWindow, mColorDepth);
+
+ mEglSurface = eglCreatePixmapSurface( mEglDisplay, mEglConfig, mEglNativePixmap, NULL );
+ TEST_EGL_ERROR("eglCreatePixmapSurface");
+
+ DALI_ASSERT_ALWAYS( mEglSurface && "Create pixmap surface failed" );
+}
+
+bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window, EGLNativeDisplayType display )
+{
+ bool contextLost = false;
+
+ // the surface is bound to the context, so set the context to null
+ MakeContextNull();
+
+ // destroy the surface
+ DestroySurface();
+
+ // If the display has not changed, then we can just create a new surface
+ if ( display == mEglNativeDisplay )
+ {
+ // create the EGL surface
+ CreateSurfaceWindow( window, mColorDepth );
+
+ // set the context to be current with the new surface
+ MakeContextCurrent();
+ }
+ else // the display has changed, we need to start egl with a new x-connection
+ {
+ // Note! this code path is untested
+
+ // this will release all EGL specific resources
+ eglTerminate( mEglDisplay );
+
+ mGlesInitialized = false;
+
+ // let the adaptor know that all resources have been lost
+ contextLost = true;
+
+ // re-initialise GLES with the new connection
+ InitializeGles( display );
+
+ // create the EGL surface
+ CreateSurfaceWindow( window, mColorDepth );
+
+ // create the OpenGL context
+ CreateContext();
+
+ // Make it current
+ MakeContextCurrent();
+ }
+
+ return contextLost;
+}
+
+bool EglImplementation::ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLNativeDisplayType display )
+{
+ bool contextLost = false;
+
+ // the surface is bound to the context, so set the context to null
+ MakeContextNull();
+
+ // destroy the surface
+ DestroySurface();
+
+ // If the display has not changed, then we can just create a new surface
+ if ( display == mEglNativeDisplay )
+ {
+ // create the EGL surface
+ CreateSurfacePixmap( pixmap, mColorDepth );
+
+ // set the context to be current with the new surface
+ MakeContextCurrent();
+ }
+ else // the display has changed, we need to start egl with a new x-connection
+ {
+ // Note! this code path is untested
+
+ // this will release all EGL specific resources
+ eglTerminate( mEglDisplay );
+
+ mGlesInitialized = false;
+
+ // let the adaptor know that all resources have been lost
+ contextLost = true;
+
+ // re-initialise GLES with the new connection
+ InitializeGles( display );
+
+ // create the EGL surface
+ CreateSurfacePixmap( pixmap, mColorDepth );
+
+ // create the OpenGL context
+ CreateContext();
+
+ // Make it current
+ MakeContextCurrent();
+ }
+ return contextLost;
+}
+
+EGLDisplay EglImplementation::GetDisplay() const
+{
+ return mEglDisplay;
+}
+
+EGLDisplay EglImplementation::GetContext() const
+{
+ return mEglContext;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <events/event-handler.h>
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+#include <Ecore_Input.h>
+#include <Ecore_X.h>
+
+#include <cstring>
+
+#include <sys/time.h>
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/events/touch-point.h>
+#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/events/mouse-wheel-event.h>
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/events/key-event-integ.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/mouse-wheel-event-integ.h>
+
+// INTERNAL INCLUDES
+#include <events/gesture-manager.h>
+#include <window-render-surface.h>
+#include <clipboard-impl.h>
+#include <key-impl.h>
+#include <physical-keyboard-impl.h>
+#include <style-monitor-impl.h>
+#include <base/core-event-interface.h>
+
+using namespace std;
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+#if defined(DEBUG_ENABLED)
+namespace
+{
+Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH");
+Integration::Log::Filter* gClientMessageLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_CLIENT_MESSAGE");
+Integration::Log::Filter* gDragAndDropLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DND");
+Integration::Log::Filter* gImfLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_IMF");
+Integration::Log::Filter* gSelectionEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_SELECTION");
+} // unnamed namespace
+#endif
+
+
+namespace
+{
+const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
+
+// Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead.
+size_t Utf8SequenceLength(const unsigned char leadByte)
+{
+ size_t length = 0;
+
+ if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero)
+ {
+ length = 1;
+ }
+ else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
+ {
+ length = 2;
+ }
+ else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
+ {
+ length = 3;
+ }
+ else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
+ {
+ length = 4;
+ }
+ else
+ {
+ DALI_LOG_WARNING("Unrecognized lead byte %c\n", leadByte);
+ }
+
+ return length;
+}
+
+const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
+
+const char * CLIPBOARD_ATOM = "CBHM_MSG";
+const char * CLIPBOARD_SET_OWNER_MESSAGE = "SET_OWNER";
+
+/// The atoms required by Ecore for Drag & Drop behaviour.
+Ecore_X_Atom DRAG_AND_DROP_ATOMS[] =
+{
+ ECORE_X_ATOM_XDND_ACTION_COPY,
+};
+
+/// The types that we support.
+const char * DRAG_AND_DROP_TYPES[] =
+{
+ ECORE_X_SELECTION_TARGET_UTF8_STRING,
+};
+
+const unsigned int DRAG_AND_DROP_ATOMS_NUMBER = sizeof( DRAG_AND_DROP_ATOMS ) / sizeof( Ecore_X_Atom );
+const unsigned int DRAG_AND_DROP_TYPES_NUMBER = sizeof( DRAG_AND_DROP_TYPES ) / sizeof( const char * );
+
+const unsigned int BYTES_PER_CHARACTER_FOR_ATTRIBUTES = 3;
+
+/**
+ * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
+ * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
+ * @param[in] ecoreModifier the Ecore_Event_Modifier input.
+ * @return the Ecore_IMF_Keyboard_Modifiers output.
+ */
+Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
+{
+ int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
+
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
+ }
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
+ }
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
+ }
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
+ }
+
+ if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
+ {
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
+ }
+
+ return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
+}
+
+
+// Copied from x server
+static unsigned int GetCurrentMilliSeconds(void)
+{
+ struct timeval tv;
+
+ struct timespec tp;
+ static clockid_t clockid;
+
+ if (!clockid)
+ {
+#ifdef CLOCK_MONOTONIC_COARSE
+ if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
+ (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
+ {
+ clockid = CLOCK_MONOTONIC_COARSE;
+ }
+ else
+#endif
+ if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+ {
+ clockid = CLOCK_MONOTONIC;
+ }
+ else
+ {
+ clockid = ~0L;
+ }
+ }
+ if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
+ {
+ return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
+ }
+
+ gettimeofday(&tv, NULL);
+ return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
+}
+
+} // unnamed namespace
+
+// Impl to hide EFL implementation.
+struct EventHandler::Impl
+{
+ // Construction & Destruction
+
+ /**
+ * Constructor
+ */
+ Impl( EventHandler* handler, Ecore_X_Window window )
+ : mHandler( handler ),
+ mEcoreEventHandler(),
+ mWindow( window )
+ {
+ // Only register for touch and key events if we have a window
+ if ( window != 0 )
+ {
+ // Register Touch events
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, handler ) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, handler ) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, handler ) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_OUT, EcoreEventMouseButtonUp, handler ) ); // process mouse out event like up event
+
+ // Register Mouse wheel events
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, handler ) );
+
+ // Register Key events
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, handler ) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, handler ) );
+
+ // Register Focus events
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_FOCUS_IN, EcoreEventWindowFocusIn, handler ) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_FOCUS_OUT, EcoreEventWindowFocusOut, handler ) );
+
+ // Register Window damage events
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_DAMAGE, EcoreEventWindowDamaged, handler ) );
+
+ // Enable Drag & Drop and register DnD events
+ ecore_x_dnd_aware_set( window, EINA_TRUE );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_ENTER, EcoreEventDndEnter, handler) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_POSITION, EcoreEventDndPosition, handler) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_LEAVE, EcoreEventDndLeave, handler) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_DROP, EcoreEventDndDrop, handler) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_FINISHED, EcoreEventDndFinished, handler) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_XDND_STATUS, EcoreEventDndStatus, handler) );
+
+ // Register Client message events - accessibility etc.
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_CLIENT_MESSAGE, EcoreEventClientMessage, handler ) );
+
+ // Register Selection event - clipboard selection, Drag & Drop selection etc.
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_SELECTION_CLEAR, EcoreEventSelectionClear, handler ) );
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_SELECTION_NOTIFY, EcoreEventSelectionNotify, handler ) );
+
+ // Register Vconf notify - font name, font size and style
+ vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, handler );
+ vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, handler );
+#if defined(DALI_PROFILE_MOBILE)
+ vconf_notify_key_changed( VCONFKEY_SETAPPL_CHANGE_UI_THEME_INT, VconfNotifyThemeChanged, handler );
+#endif
+ }
+ }
+
+ /**
+ * Destructor
+ */
+ ~Impl()
+ {
+#if defined(DALI_PROFILE_MOBILE)
+ vconf_ignore_key_changed( VCONFKEY_SETAPPL_CHANGE_UI_THEME_INT, VconfNotifyThemeChanged );
+#endif
+ vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
+ vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
+
+ for( std::vector<Ecore_Event_Handler*>::iterator iter = mEcoreEventHandler.begin(), endIter = mEcoreEventHandler.end(); iter != endIter; ++iter )
+ {
+ ecore_event_handler_del( *iter );
+ }
+ }
+
+ // Static methods
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ // Touch Callbacks
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Called when a touch down is received.
+ */
+ static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
+ {
+ Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if ( touchEvent->window == handler->mImpl->mWindow )
+ {
+ TouchPoint::State state ( TouchPoint::Down );
+
+ // Check if the buttons field is set and ensure it's the primary touch button.
+ // If this event was triggered by buttons other than the primary button (used for touch), then
+ // just send an interrupted event to Core.
+ if ( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
+ {
+ state = TouchPoint::Interrupted;
+ }
+
+ TouchPoint point( touchEvent->multi.device, state, touchEvent->x, touchEvent->y );
+ handler->SendEvent( point, touchEvent->timestamp );
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a touch up is received.
+ */
+ static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
+ {
+ Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if ( touchEvent->window == handler->mImpl->mWindow )
+ {
+ TouchPoint point( touchEvent->multi.device, TouchPoint::Up, touchEvent->x, touchEvent->y );
+ handler->SendEvent( point, touchEvent->timestamp );
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a touch up is received.
+ */
+ static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
+ {
+ Ecore_Event_Mouse_Wheel *mouseWheelEvent( (Ecore_Event_Mouse_Wheel*)event );
+
+ DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT Ecore_Event_Mouse_Wheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z);
+
+ EventHandler* handler( (EventHandler*)data );
+ if ( mouseWheelEvent->window == handler->mImpl->mWindow )
+ {
+ MouseWheelEvent wheelEvent(mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
+ handler->SendMouseWheelEvent( wheelEvent );
+ }
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a touch motion is received.
+ */
+ static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
+ {
+ Ecore_Event_Mouse_Move *touchEvent( (Ecore_Event_Mouse_Move*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if ( touchEvent->window == handler->mImpl->mWindow )
+ {
+ TouchPoint point( touchEvent->multi.device, TouchPoint::Motion, touchEvent->x, touchEvent->y );
+ handler->SendEvent( point, touchEvent->timestamp );
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ // Key Callbacks
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Called when a key down is received.
+ */
+ static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyDown \n" );
+
+ EventHandler* handler( (EventHandler*)data );
+ Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
+ bool eventHandled( false );
+
+ Ecore_IMF_Context* imfContext = NULL;
+ if ( Dali::Adaptor::IsAvailable() && handler->mImfManager )
+ {
+ imfContext = reinterpret_cast<Ecore_IMF_Context*>( handler->mImfManager.GetContext() );
+ }
+
+ // If a device key then skip ecore_imf_context_filter_event.
+ if ( imfContext && !( KeyLookup::IsDeviceButton( keyEvent->keyname ) ) )
+ {
+ // We're consuming key down event so we have to pass to IMF so that it can parse it as well.
+ Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
+ ecoreKeyDownEvent.keyname = keyEvent->keyname;
+ ecoreKeyDownEvent.key = keyEvent->key;
+ ecoreKeyDownEvent.string = keyEvent->string;
+ ecoreKeyDownEvent.compose = keyEvent->compose;
+ ecoreKeyDownEvent.timestamp = keyEvent->timestamp;
+ ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
+ ecoreKeyDownEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
+
+ eventHandled = ecore_imf_context_filter_event( imfContext,
+ ECORE_IMF_EVENT_KEY_DOWN,
+ (Ecore_IMF_Event *) &ecoreKeyDownEvent );
+
+ // If the event has not been handled by IMF then check if we should reset our IMF context
+ if( !eventHandled )
+ {
+ if ( !strcmp( keyEvent->keyname, "Escape" ) ||
+ !strcmp( keyEvent->keyname, "Return" ) ||
+ !strcmp( keyEvent->keyname, "KP_Enter" ) )
+ {
+ ecore_imf_context_reset( imfContext );
+ }
+ }
+ }
+
+ // If the event wasn't handled then we should send a key event.
+ if ( !eventHandled )
+ {
+ if ( keyEvent->window == handler->mImpl->mWindow )
+ {
+ std::string keyName( keyEvent->keyname );
+ std::string keyString( "" );
+ int keyCode = ecore_x_keysym_keycode_get(keyEvent->keyname);
+ int modifier( keyEvent->modifiers );
+ unsigned long time = keyEvent->timestamp;
+
+ // Ensure key event string is not NULL as keys like SHIFT have a null string.
+ if ( keyEvent->string )
+ {
+ keyString = keyEvent->string;
+ }
+
+ KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, KeyEvent::Down);
+ handler->SendEvent( keyEvent );
+ }
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a key up is received.
+ */
+ static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyUp \n" );
+
+ EventHandler* handler( (EventHandler*)data );
+ Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
+ bool eventHandled( false );
+
+ Ecore_IMF_Context* imfContext = NULL;
+ if ( Dali::Adaptor::IsAvailable() && handler->mImfManager )
+ {
+ imfContext = reinterpret_cast<Ecore_IMF_Context*>( handler->mImfManager.GetContext() );
+ }
+
+ // XF86Stop and XF86Send must skip ecore_imf_context_filter_event.
+ if ( imfContext && strcmp( keyEvent->keyname, "XF86Send" ) && strcmp( keyEvent->keyname, "XF86Phone" ) && strcmp( keyEvent->keyname, "XF86Stop" ) )
+
+ {
+ // We're consuming key up event so we have to pass to IMF so that it can parse it as well.
+ Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
+ ecoreKeyUpEvent.keyname = keyEvent->keyname;
+ ecoreKeyUpEvent.key = keyEvent->key;
+ ecoreKeyUpEvent.string = keyEvent->string;
+ ecoreKeyUpEvent.compose = keyEvent->compose;
+ ecoreKeyUpEvent.timestamp = keyEvent->timestamp;
+ ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
+ ecoreKeyUpEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
+
+ eventHandled = ecore_imf_context_filter_event( imfContext,
+ ECORE_IMF_EVENT_KEY_UP,
+ (Ecore_IMF_Event *) &ecoreKeyUpEvent );
+ }
+
+ // If the event wasn't handled then we should send a key event.
+ if ( !eventHandled )
+ {
+ if ( keyEvent->window == handler->mImpl->mWindow )
+ {
+ std::string keyName( keyEvent->keyname );
+ std::string keyString( "" );
+ int keyCode = ecore_x_keysym_keycode_get(keyEvent->keyname);
+ int modifier( keyEvent->modifiers );
+ unsigned long time( keyEvent->timestamp );
+
+ // Ensure key event string is not NULL as keys like SHIFT have a null string.
+ if ( keyEvent->string )
+ {
+ keyString = keyEvent->string;
+ }
+
+ KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, KeyEvent::Up);
+ handler->SendEvent( keyEvent );
+
+ }
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ // Window Callbacks
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Called when the window gains focus.
+ */
+ static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
+ {
+ Ecore_X_Event_Window_Focus_In* focusInEvent( (Ecore_X_Event_Window_Focus_In*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusIn \n" );
+
+ // If the window gains focus and we hid the keyboard then show it again.
+ if ( focusInEvent->win == handler->mImpl->mWindow )
+ {
+ DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventWindowFocusIn - >>WindowFocusGained \n" );
+
+ if ( handler->mImfManager )
+ {
+ ImfManager& imfManager( ImfManager::GetImplementation( handler->mImfManager ) );
+ if( imfManager.RestoreAfterFocusLost() )
+ {
+ imfManager.Activate();
+ }
+ }
+ // No need to connect callbacks as KeyboardStatusChanged will be called.
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the window loses focus.
+ */
+ static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
+ {
+ Ecore_X_Event_Window_Focus_Out* focusOutEvent( (Ecore_X_Event_Window_Focus_Out*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusOut \n" );
+
+ // If the window loses focus then hide the keyboard.
+ if ( focusOutEvent->win == handler->mImpl->mWindow )
+ {
+ if ( handler->mImfManager )
+ {
+ ImfManager& imfManager( ImfManager::GetImplementation( handler->mImfManager ) );
+ if( imfManager.RestoreAfterFocusLost() )
+ {
+ imfManager.Deactivate();
+ }
+ }
+
+ // Clipboard don't support that whether clipboard is shown or not. Hide clipboard.
+ Dali::Clipboard clipboard = Clipboard::Get();
+ clipboard.HideClipboard();
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the window is damaged.
+ */
+ static Eina_Bool EcoreEventWindowDamaged(void *data, int type, void *event)
+ {
+ Ecore_X_Event_Window_Damage* windowDamagedEvent( (Ecore_X_Event_Window_Damage*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if( windowDamagedEvent->win == handler->mImpl->mWindow )
+ {
+ DamageArea area;
+ area.x = windowDamagedEvent->x;
+ area.y = windowDamagedEvent->y;
+ area.width = windowDamagedEvent->w;
+ area.height = windowDamagedEvent->h;
+
+ handler->SendEvent( area );
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the window properties are changed.
+ * We are only interested in the font change.
+ */
+
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ // Drag & Drop Callbacks
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Called when a dragged item enters our window's bounds.
+ * This is when items are dragged INTO our window.
+ */
+ static Eina_Bool EcoreEventDndEnter( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO( gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndEnter\n" );
+
+ Ecore_X_Event_Xdnd_Enter* enterEvent( (Ecore_X_Event_Xdnd_Enter*) event );
+ EventHandler* handler( (EventHandler*)data );
+ Ecore_X_Window window ( handler->mImpl->mWindow );
+
+ if ( enterEvent->win == window )
+ {
+ DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
+
+ // Check whether the Drag & Drop detector has Drag & Drop behaviour enabled before we accept.
+ if ( dndDetector && dndDetector->IsEnabled() )
+ {
+ // Tell Ecore that we want to enable drop in the entire window.
+ Ecore_X_Rectangle rect;
+ rect.x = rect.y = 0;
+ ecore_x_window_geometry_get( window, NULL, NULL, (int*)&rect.width, (int*)&rect.height );
+
+ // Tell Ecore that we are able to process a drop.
+ ecore_x_dnd_send_status( EINA_TRUE, EINA_FALSE, rect, ECORE_X_ATOM_XDND_DROP );
+
+ // Register the required atoms and types.
+ ecore_x_dnd_actions_set( window, DRAG_AND_DROP_ATOMS, DRAG_AND_DROP_ATOMS_NUMBER );
+ ecore_x_dnd_types_set( window, DRAG_AND_DROP_TYPES, DRAG_AND_DROP_TYPES_NUMBER );
+
+ // Request to get the content from Ecore.
+ ecore_x_selection_xdnd_request( window, ECORE_X_SELECTION_TARGET_UTF8_STRING );
+
+ DALI_LOG_INFO( gDragAndDropLogFilter, Debug::General, "EcoreEventDndEnter: Requesting Drag & Drop\n" );
+
+ // Clear the previous content
+ dndDetector->ClearContent();
+
+ // Emit the entered signal
+ dndDetector->EmitEnteredSignal();
+ }
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a dragged item is moved within our window.
+ * This is when items are dragged INTO our window.
+ */
+ static Eina_Bool EcoreEventDndPosition( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndPosition\n" );
+
+ Ecore_X_Event_Xdnd_Position* positionEvent( (Ecore_X_Event_Xdnd_Position*) event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if ( positionEvent->win == handler->mImpl->mWindow )
+ {
+ DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
+
+ // If we have a detector then update its latest position.
+ if ( dndDetector )
+ {
+ DALI_LOG_INFO(gDragAndDropLogFilter, Debug::General, "EcoreEventDndPosition: position ( %d x %d )\n", positionEvent->position.x, positionEvent->position.y );
+ dndDetector->SetPosition( Vector2( positionEvent->position.x, positionEvent->position.y ));
+ dndDetector->EmitMovedSignal();
+ }
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a dragged item leaves our window's bounds.
+ * This is when items are dragged INTO our window.
+ */
+ static Eina_Bool EcoreEventDndLeave( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndLeave\n" );
+
+ Ecore_X_Event_Xdnd_Leave* leaveEvent( (Ecore_X_Event_Xdnd_Leave*) event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if ( leaveEvent->win == handler->mImpl->mWindow )
+ {
+ DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
+
+ // If we have a detector then clear its content and emit the exited-signal. Also tell Ecore that we have finished.
+ if ( dndDetector )
+ {
+ dndDetector->ClearContent();
+ dndDetector->EmitExitedSignal();
+
+ ecore_x_dnd_send_finished();
+
+ DALI_LOG_INFO( gDragAndDropLogFilter, Debug::General, "EcoreEventDndLeave: Finished\n" );
+ }
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the dragged item is dropped within our window's bounds.
+ * This is when items are dragged INTO our window.
+ */
+ static Eina_Bool EcoreEventDndDrop( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndDrop\n" );
+
+ Ecore_X_Event_Xdnd_Drop* dropEvent ( (Ecore_X_Event_Xdnd_Drop*) event);
+ EventHandler* handler( (EventHandler*)data );
+
+ if ( dropEvent->win == handler->mImpl->mWindow )
+ {
+ DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
+
+ // Something has been dropped, inform the detector (if we have one) and tell Ecore that we have finished.
+ if ( dndDetector )
+ {
+ DALI_LOG_INFO(gDragAndDropLogFilter, Debug::General, "EcoreEventDndDrop: position ( %d x %d )\n", dropEvent->position.x, dropEvent->position.y );
+
+ dndDetector->SetPosition( Vector2( dropEvent->position.x, dropEvent->position.y ) );
+ dndDetector->EmitDroppedSignal();
+ ecore_x_dnd_send_finished();
+
+ DALI_LOG_INFO( gDragAndDropLogFilter, Debug::General, "EcoreEventDndDrop: Finished\n" );
+ }
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a dragged item is moved from our window and the target window has done processing it.
+ * This is when items are dragged FROM our window.
+ */
+ static Eina_Bool EcoreEventDndFinished( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndFinished\n" );
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when a dragged item is moved from our window and the target window has sent us a status.
+ * This is when items are dragged FROM our window.
+ */
+ static Eina_Bool EcoreEventDndStatus( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndStatus\n" );
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the client messages (i.e. the accessibility events) are received.
+ */
+ static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
+ {
+ Ecore_X_Event_Client_Message* clientMessageEvent( (Ecore_X_Event_Client_Message*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if (clientMessageEvent->message_type == ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL)
+ {
+ if ( ( (unsigned int)clientMessageEvent->data.l[0] == handler->mImpl->mWindow ) && handler->mAccessibilityManager )
+ {
+ AccessibilityManager* accessibilityManager( &AccessibilityManager::GetImplementation( handler->mAccessibilityManager ) );
+
+ if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_SCROLL)
+ {
+ // 2 finger touch & move, 2 finger flick
+
+ // mouse state : e->data.l[2] (0: mouse down, 1: mouse move, 2: mouse up)
+ // x : e->data.l[3]
+ // y : e->data.l[4]
+ TouchPoint::State state(TouchPoint::Down);
+
+ if ((unsigned int)clientMessageEvent->data.l[2] == 0)
+ {
+ state = TouchPoint::Down; // mouse down
+ }
+ else if ((unsigned int)clientMessageEvent->data.l[2] == 1)
+ {
+ state = TouchPoint::Motion; // mouse move
+ }
+ else if ((unsigned int)clientMessageEvent->data.l[2] == 2)
+ {
+ state = TouchPoint::Up; // mouse up
+ }
+ else
+ {
+ state = TouchPoint::Interrupted; // error
+ }
+
+ DALI_LOG_INFO(gClientMessageLogFilter, Debug::General,
+ "[%s:%d] [%d] %d, %d\n", __FUNCTION__, __LINE__,
+ (unsigned int)clientMessageEvent->data.l[2],
+ (unsigned int)clientMessageEvent->data.l[3], (unsigned int)clientMessageEvent->data.l[4]);
+
+ // Send touch event to accessibility manager.
+ TouchPoint point( 0, state, (float)clientMessageEvent->data.l[3], (float)clientMessageEvent->data.l[4] );
+
+ // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
+ accessibilityManager->HandleActionScrollEvent( point, GetCurrentMilliSeconds() );
+ }
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_MOUSE)
+ {
+ // 1 finger double tap and hold
+
+ // mouse state : e->data.l[2] (0: mouse down, 1: mouse move, 2: mouse up)
+ // x : e->data.l[3]
+ // y : e->data.l[4]
+ TouchPoint::State state(TouchPoint::Down);
+
+ if ((unsigned int)clientMessageEvent->data.l[2] == 0)
+ {
+ state = TouchPoint::Down; // mouse down
+ }
+ else if ((unsigned int)clientMessageEvent->data.l[2] == 1)
+ {
+ state = TouchPoint::Motion; // mouse move
+ }
+ else if ((unsigned int)clientMessageEvent->data.l[2] == 2)
+ {
+ state = TouchPoint::Up; // mouse up
+ }
+ else
+ {
+ state = TouchPoint::Interrupted; // error
+ }
+
+ DALI_LOG_INFO(gClientMessageLogFilter, Debug::General,
+ "[%s:%d] [%d] %d, %d\n", __FUNCTION__, __LINE__,
+ (unsigned int)clientMessageEvent->data.l[2],
+ (unsigned int)clientMessageEvent->data.l[3], (unsigned int)clientMessageEvent->data.l[4]);
+
+ // Send touch event to accessibility manager.
+ TouchPoint point( 0, state, (float)clientMessageEvent->data.l[3], (float)clientMessageEvent->data.l[4] );
+
+ // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
+ accessibilityManager->HandleActionTouchEvent( point, GetCurrentMilliSeconds() );
+ }
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_BACK)
+ {
+ // 2 finger circle draw, do back
+ accessibilityManager->HandleActionBackEvent();
+ }
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_NEXT)
+ {
+ // one finger flick down
+ // focus next object
+ if(accessibilityManager)
+ {
+ accessibilityManager->HandleActionNextEvent();
+ }
+ }
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_PREV)
+ {
+ // one finger flick up
+ // focus previous object
+ if(accessibilityManager)
+ {
+ accessibilityManager->HandleActionPreviousEvent();
+ }
+ }
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE)
+ {
+ // one finger double tap
+ // same as one finger tap in normal mode (i.e. execute focused actor)
+ if(accessibilityManager)
+ {
+ accessibilityManager->HandleActionActivateEvent();
+ }
+ }
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ)
+ {
+ // one finger tap
+ // focus & read an actor at ( e->data.l[2], e->data.l[3] ) position according to finger
+ if(accessibilityManager)
+ {
+ accessibilityManager->HandleActionReadEvent((unsigned int)clientMessageEvent->data.l[2], (unsigned int)clientMessageEvent->data.l[3], true /* allow read again*/);
+ }
+ }
+#if defined(DALI_PROFILE_MOBILE) || defined(DALI_PROFILE_TV)
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_OVER)
+ {
+ // one finger tap & move
+ // mouse state : e->data.l[2] (0: mouse down, 1: mouse move, 2: mouse up)
+ // x : e->data.l[3]
+ // y : e->data.l[4]
+ // focus & read an actor at (x, y) position according to finger
+ if(accessibilityManager && (unsigned int)clientMessageEvent->data.l[2] == 1 /*only work for move event*/)
+ {
+ accessibilityManager->HandleActionReadEvent((unsigned int)clientMessageEvent->data.l[3], (unsigned int)clientMessageEvent->data.l[4], false /* not allow read again*/);
+ }
+ }
+#endif
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_NEXT)
+ {
+ // one finger flick right
+ // focus next object
+ if(accessibilityManager)
+ {
+ accessibilityManager->HandleActionReadNextEvent();
+ }
+ }
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_PREV)
+ {
+ // one finger flick left
+ // focus previous object
+ if(accessibilityManager)
+ {
+ accessibilityManager->HandleActionReadPreviousEvent();
+ }
+ }
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_UP)
+ {
+ // double down and move (right, up)
+ // change slider value
+ if(accessibilityManager)
+ {
+ accessibilityManager->HandleActionUpEvent();
+ }
+ }
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DOWN)
+ {
+ // double down and move (left, down)
+ // change slider value
+ if(accessibilityManager)
+ {
+ accessibilityManager->HandleActionDownEvent();
+ }
+ }
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ENABLE)
+ {
+ if(accessibilityManager)
+ {
+ accessibilityManager->HandleActionEnableEvent();
+ }
+ }
+ else if((unsigned int)clientMessageEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DISABLE)
+ {
+ if(accessibilityManager)
+ {
+ accessibilityManager->HandleActionDisableEvent();
+ }
+ }
+ // TODO: some more actions could be added later
+ }
+ }
+ else if(clientMessageEvent->message_type == ecore_x_atom_get(CLIPBOARD_ATOM))
+ {
+ std::string message(clientMessageEvent->data.b);
+ if( message == CLIPBOARD_SET_OWNER_MESSAGE)
+ {
+ // Claim the ownership of the SECONDARY selection.
+ ecore_x_selection_secondary_set(handler->mImpl->mWindow, "", 1);
+
+ // Show the clipboard window
+ Dali::Clipboard clipboard = Dali::Clipboard::Get();
+ clipboard.ShowClipboard();
+ }
+ }
+ else if( clientMessageEvent->message_type == ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_PREPARE )
+ {
+ RotationEvent rotationEvent;
+ rotationEvent.angle = static_cast<int>(clientMessageEvent->data.l[1]);
+ rotationEvent.winResize = static_cast<int>(clientMessageEvent->data.l[2]);
+ rotationEvent.width = static_cast<int>(clientMessageEvent->data.l[3]);
+ rotationEvent.height = static_cast<int>(clientMessageEvent->data.l[4]);
+ handler->SendRotationPrepareEvent( rotationEvent );
+ }
+ else if( clientMessageEvent->message_type == ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST )
+ {
+ handler->SendRotationRequestEvent();
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the source window notifies us the content in clipboard is selected.
+ */
+ static Eina_Bool EcoreEventSelectionClear( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionClear\n" );
+ Ecore_X_Event_Selection_Clear* selectionClearEvent( (Ecore_X_Event_Selection_Clear*) event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if ( selectionClearEvent->win == handler->mImpl->mWindow )
+ {
+ if ( selectionClearEvent->selection == ECORE_X_SELECTION_SECONDARY )
+ {
+ // Request to get the content from Ecore.
+ ecore_x_selection_secondary_request(selectionClearEvent->win, ECORE_X_SELECTION_TARGET_TEXT);
+ }
+ }
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /**
+ * Called when the source window sends us about the selected content.
+ * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
+ */
+ static Eina_Bool EcoreEventSelectionNotify( void* data, int type, void* event )
+ {
+ DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionNotify\n" );
+
+ Ecore_X_Event_Selection_Notify* selectionNotifyEvent( (Ecore_X_Event_Selection_Notify*) event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if ( selectionNotifyEvent->win == handler->mImpl->mWindow )
+ {
+ Ecore_X_Selection_Data* selectionData( (Ecore_X_Selection_Data*) selectionNotifyEvent->data );
+ if ( selectionData->data )
+ {
+ if ( selectionNotifyEvent->selection == ECORE_X_SELECTION_XDND )
+ {
+ DragAndDropDetectorPtr dndDetector( handler->mDragAndDropDetector );
+
+ // We have got the content that is to be dropped, inform the DndListener (if we have one).
+ if ( dndDetector )
+ {
+ std::string content( (char*) selectionData->data, selectionData->length );
+ dndDetector->SetContent( content );
+
+ DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "EcoreEventSelectionNotify: Content(%d):\n" , selectionData->length );
+ DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "======================================\n" );
+ DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "%s\n", selectionData->data );
+ DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "======================================\n" );
+ }
+ }
+ else if ( selectionNotifyEvent->selection == ECORE_X_SELECTION_SECONDARY )
+ {
+ // We have got the selected content, inform the clipboard event listener (if we have one).
+ if ( handler->mClipboardEventNotifier )
+ {
+ ClipboardEventNotifier& clipboardEventNotifier( ClipboardEventNotifier::GetImplementation( handler->mClipboardEventNotifier ) );
+ std::string content( (char*) selectionData->data, selectionData->length );
+ clipboardEventNotifier.SetContent( content );
+ clipboardEventNotifier.EmitContentSelectedSignal();
+ }
+
+ // Claim the ownership of the SECONDARY selection.
+ ecore_x_selection_secondary_set(handler->mImpl->mWindow, "", 1);
+
+ DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "EcoreEventSelectionNotify: Content(%d):\n" , selectionData->length );
+ DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "======================================\n" );
+ DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "%s\n", selectionData->data );
+ DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "======================================\n" );
+ }
+ }
+ }
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ // Font Callbacks
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Called when a font name is changed.
+ */
+ static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
+ {
+ EventHandler* handler = static_cast<EventHandler*>( data );
+
+ StyleChange fontChange;
+ fontChange.defaultFontChange = true;
+
+ handler->SendEvent( fontChange );
+ }
+
+ /**
+ * Called when a font size is changed.
+ */
+ static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
+ {
+ EventHandler* handler = static_cast<EventHandler*>( data );
+
+ StyleChange fontChange;
+ fontChange.defaultFontSizeChange = true;
+
+ handler->SendEvent( fontChange );
+ }
+
+ /**
+ * Called when style is changed
+ */
+ static void VconfNotifyThemeChanged( keynode_t* node, void* data )
+ {
+ EventHandler* handler( static_cast<EventHandler*>(data) );
+
+ StyleChange themeChange;
+ themeChange.themeChange = true;
+
+ handler->SendEvent( themeChange );
+ }
+
+ // Data
+ EventHandler* mHandler;
+ std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
+ Ecore_X_Window mWindow;
+};
+
+EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
+: mCoreEventInterface(coreEventInterface),
+ mGestureManager( gestureManager ),
+ mStyleMonitor( StyleMonitor::Get() ),
+ mDamageObserver( damageObserver ),
+ mRotationObserver( NULL ),
+ mDragAndDropDetector( dndDetector ),
+ mAccessibilityManager( AccessibilityManager::Get() ),
+ mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
+ mClipboard(Clipboard::Get()),
+ mImfManager( ImfManager::Get() ),
+ mImpl( NULL )
+{
+ Ecore_X_Window window = 0;
+
+ if( surface->GetType() == Dali::RenderSurface::WINDOW )
+ {
+ // this code only works with the EcoreX11 RenderSurface so need to downcast
+ ECore::WindowRenderSurface* ecoreSurface = dynamic_cast< ECore::WindowRenderSurface* >( surface );
+ if( ecoreSurface )
+ {
+ // enable multi touch
+ window = ecoreSurface->GetXWindow();
+ ecore_x_input_multi_select( window );
+ }
+ }
+
+ mImpl = new Impl(this, window);
+}
+
+EventHandler::~EventHandler()
+{
+ if(mImpl)
+ {
+ delete mImpl;
+ }
+
+ mGestureManager.Stop();
+}
+
+void EventHandler::SendEvent(TouchPoint& point, unsigned long timeStamp)
+{
+ if(timeStamp < 1)
+ {
+ timeStamp = GetCurrentMilliSeconds();
+ }
+
+ Integration::TouchEvent event;
+ if (mCombiner.GetNextTouchEvent(point, timeStamp, event))
+ {
+ DALI_LOG_INFO(gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.deviceId, point.state, point.local.x, point.local.y);
+
+ // First the touch event & related gesture events are queued
+ mCoreEventInterface.QueueCoreEvent( event );
+ mGestureManager.SendEvent(event);
+
+ // Next the events are processed with a single call into Core
+ mCoreEventInterface.ProcessCoreEvents();
+ }
+}
+
+void EventHandler::SendEvent(KeyEvent& keyEvent)
+{
+ Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
+ if ( physicalKeyboard )
+ {
+ if ( ! KeyLookup::IsDeviceButton( keyEvent.keyPressedName.c_str() ) )
+ {
+ GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
+ }
+ }
+
+ // Create KeyEvent and send to Core.
+ Integration::KeyEvent event(keyEvent.keyPressedName, keyEvent.keyPressed, keyEvent.keyCode,
+ keyEvent.keyModifier, keyEvent.time, static_cast<Integration::KeyEvent::State>(keyEvent.state));
+ mCoreEventInterface.QueueCoreEvent( event );
+ mCoreEventInterface.ProcessCoreEvents();
+}
+
+void EventHandler::SendMouseWheelEvent( MouseWheelEvent& wheelEvent )
+{
+ // Create MouseWheelEvent and send to Core.
+ Integration::MouseWheelEvent event(wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp);
+ mCoreEventInterface.QueueCoreEvent( event );
+ mCoreEventInterface.ProcessCoreEvents();
+}
+
+void EventHandler::SendEvent(StyleChange styleChange)
+{
+ DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
+ GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
+}
+
+void EventHandler::SendEvent( const DamageArea& area )
+{
+ mDamageObserver.OnDamaged( area );
+}
+
+void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
+{
+ if( mRotationObserver != NULL )
+ {
+ mRotationObserver->OnRotationPrepare( event );
+ }
+}
+
+void EventHandler::SendRotationRequestEvent( )
+{
+ if( mRotationObserver != NULL )
+ {
+ mRotationObserver->OnRotationRequest( );
+ }
+}
+
+void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
+{
+ SendEvent(point, timeStamp);
+}
+
+void EventHandler::FeedWheelEvent( MouseWheelEvent& wheelEvent )
+{
+ SendMouseWheelEvent( wheelEvent );
+}
+
+void EventHandler::FeedKeyEvent( KeyEvent& event )
+{
+ SendEvent( event );
+}
+
+void EventHandler::FeedEvent( Integration::Event& event )
+{
+ mCoreEventInterface.QueueCoreEvent( event );
+ mCoreEventInterface.ProcessCoreEvents();
+}
+
+void EventHandler::Reset()
+{
+ mCombiner.Reset();
+
+ // Any touch listeners should be told of the interruption.
+ Integration::TouchEvent event;
+ TouchPoint point(0, TouchPoint::Interrupted, 0, 0);
+ event.AddPoint( point );
+
+ // First the touch event & related gesture events are queued
+ mCoreEventInterface.QueueCoreEvent( event );
+ mGestureManager.SendEvent( event );
+
+ // Next the events are processed with a single call into Core
+ mCoreEventInterface.ProcessCoreEvents();
+}
+
+void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
+{
+ mDragAndDropDetector = detector;
+}
+
+void EventHandler::SetRotationObserver( RotationObserver* observer )
+{
+ mRotationObserver = observer;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+# x11
+
+adaptor_x11_internal_header_files = \
+ $(adaptor_x11_dir)/clipboard-impl.h \
+ $(adaptor_x11_dir)/imf-manager-impl.h \
+ $(adaptor_x11_dir)/pixmap-image-impl.h \
+ $(adaptor_x11_dir)/pixmap-render-surface.h
+
+adaptor_x11_application_src_files = \
+ $(adaptor_x11_dir)/framework-x.cpp
+
+adaptor_x11_internal_src_files = \
+ $(adaptor_x11_dir)/accessibility-manager-impl-x.cpp \
+ $(adaptor_x11_dir)/clipboard-impl-x.cpp \
+ $(adaptor_x11_dir)/imf-manager-impl-x.cpp \
+ $(adaptor_x11_dir)/pixmap-image-impl-x.cpp \
+ $(adaptor_x11_dir)/server-connection-x.cpp \
+ $(adaptor_x11_dir)/virtual-keyboard-impl-x.cpp \
+ $(adaptor_x11_dir)/window-impl-x.cpp \
+ $(adaptor_x11_dir)/event-handler-x.cpp \
+ $(adaptor_x11_dir)/egl-implementation-x.cpp \
+ $(adaptor_x11_dir)/pixmap-render-surface-x.cpp \
+ $(adaptor_x11_dir)/ecore-x-render-surface.cpp \
+ $(adaptor_x11_dir)/window-render-surface-x.cpp \
+ $(adaptor_x11_dir)/ecore-x-window-interface.cpp
+
+adaptor_x11_profile_src_files = \
+ $(adaptor_x11_dir)/key-impl-x.cpp
+
+adaptor_x11_common_internal_profile_src_files = \
+ $(adaptor_x11_dir)/ecore-x-render-surface-factory.cpp \
+ $(adaptor_x11_dir)/system-settings-x.cpp
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "framework.h"
+
+// EXTERNAL INCLUDES
+#include <X11/Xlib.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+void Framework::InitThreads()
+{
+ XInitThreads();
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <imf-manager-impl.h>
+
+// EXTERNAL INCLUDES
+#include <boost/bind.hpp>
+#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/object/type-registry.h>
+#include <adaptor.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <window-render-surface.h>
+#include <adaptor-impl.h>
+#include <virtual-keyboard-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_IMF_MANAGER");
+#endif
+
+// Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead.
+size_t Utf8SequenceLength(const unsigned char leadByte)
+{
+ size_t length = 0;
+
+ if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero)
+ {
+ length = 1;
+ }
+ else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
+ {
+ length = 2;
+ }
+ else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
+ {
+ length = 3;
+ }
+ else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
+ {
+ length = 4;
+ }
+
+ return length;
+}
+
+// Static function calls used by ecore 'c' style callback registration
+void Commit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
+{
+ if ( data )
+ {
+ ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
+ imfManager->CommitReceived( data, imfContext, event_info );
+ }
+}
+
+void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
+{
+ if ( data )
+ {
+ ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
+ imfManager->PreEditChanged( data, imfContext, event_info );
+ }
+}
+
+Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
+{
+ if ( data )
+ {
+ ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
+ return imfManager->RetrieveSurrounding( data, imfContext, text, cursorPosition );
+ }
+ else
+ {
+ return false;
+ }
+}
+
+/**
+ * Called when an IMF delete surrounding event is received.
+ * Here we tell the application that it should delete a certain range.
+ */
+void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
+{
+ if ( data )
+ {
+ ImfManager* imfManager = reinterpret_cast< ImfManager* > ( data );
+ imfManager->DeleteSurrounding( data, imfContext, event_info );
+ }
+}
+
+BaseHandle Create()
+{
+ BaseHandle handle( ImfManager::Get() );
+
+ if ( !handle && Adaptor::IsAvailable() )
+ {
+ Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
+
+ // The Ecore_X_Window needs to use the ImfManager.
+ // Only when the render surface is window, we can get the Ecore_X_Window.
+ Ecore_X_Window ecoreXwin( 0 );
+ Dali::RenderSurface& surface( adaptorImpl.GetSurface() );
+ if( surface.GetType() == Dali::RenderSurface::WINDOW )
+ {
+ ecoreXwin = AnyCast< Ecore_X_Window >( adaptorImpl.GetSurface().GetSurface() );
+ }
+
+ // If we fail to get Ecore_X_Window, we can't use the ImfManager correctly.
+ // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
+ // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
+
+ Dali::ImfManager manager = Dali::ImfManager( new ImfManager( ecoreXwin ) );
+ adaptorImpl.RegisterSingleton( typeid( manager ), manager );
+ handle = manager;
+ }
+
+ return handle;
+}
+
+TypeRegistration IMF_MANAGER_TYPE( typeid(Dali::ImfManager), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
+
+} // unnamed namespace
+
+Dali::ImfManager ImfManager::Get()
+{
+ Dali::ImfManager manager;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::ImfManager ) );
+ if(handle)
+ {
+ // If so, downcast the handle
+ manager = Dali::ImfManager( dynamic_cast< ImfManager* >( handle.GetObjectPtr() ) );
+ }
+ }
+
+ return manager;
+}
+
+ImfManager::ImfManager( Ecore_X_Window ecoreXwin )
+: mIMFContext(),
+ mIMFCursorPosition( 0 ),
+ mSurroundingText(""),
+ mRestoreAfterFocusLost( false ),
+ mIdleCallbackConnected( false ),
+ mKeyEvents()
+{
+ ecore_imf_init();
+ CreateContext( ecoreXwin );
+
+ ConnectCallbacks();
+ VirtualKeyboard::ConnectCallbacks( mIMFContext );
+}
+
+ImfManager::~ImfManager()
+{
+ VirtualKeyboard::DisconnectCallbacks( mIMFContext );
+ DisconnectCallbacks();
+
+ DeleteContext();
+ ecore_imf_shutdown();
+}
+
+void ImfManager::CreateContext( Ecore_X_Window ecoreXwin )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CreateContext\n" );
+
+ const char *contextId = ecore_imf_context_default_id_get();
+ if( contextId )
+ {
+ mIMFContext = ecore_imf_context_add( contextId );
+
+ if( mIMFContext )
+ {
+ if( ecoreXwin )
+ {
+ ecore_imf_context_client_window_set( mIMFContext, reinterpret_cast<void*>( ecoreXwin ) );
+ }
+ }
+ else
+ {
+ DALI_LOG_WARNING("IMF Unable to get IMF Context\n");
+ }
+ }
+ else
+ {
+ DALI_LOG_WARNING("IMF Unable to get IMF Context\n");
+ }
+}
+
+void ImfManager::DeleteContext()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteContext\n" );
+
+ if ( mIMFContext )
+ {
+ mIMFContext = NULL;
+ }
+}
+
+// Callbacks for predicitive text support.
+void ImfManager::ConnectCallbacks()
+{
+ if ( mIMFContext )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::ConnectCallbacks\n" );
+
+ ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this );
+ ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this );
+ ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this );
+
+ ecore_imf_context_retrieve_surrounding_callback_set( mIMFContext, ImfRetrieveSurrounding, this);
+ }
+}
+
+void ImfManager::DisconnectCallbacks()
+{
+ if ( mIMFContext )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DisconnectCallbacks\n" );
+
+ ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit );
+ ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit );
+ ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding );
+
+ // We do not need to unset the retrieve surrounding callback.
+ }
+}
+
+void ImfManager::Activate()
+{
+ // Reset mIdleCallbackConnected
+ mIdleCallbackConnected = false;
+
+ if ( mIMFContext )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Activate\n" );
+
+ ecore_imf_context_focus_in( mIMFContext );
+
+ // emit keyboard activated signal
+ Dali::ImfManager handle( this );
+ mActivatedSignalV2.Emit( handle );
+ }
+}
+
+void ImfManager::Deactivate()
+{
+ if( mIMFContext )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Deactivate\n" );
+
+ Reset();
+ ecore_imf_context_focus_out( mIMFContext );
+ }
+
+ // Reset mIdleCallbackConnected
+ mIdleCallbackConnected = false;
+}
+
+void ImfManager::Reset()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Reset\n" );
+
+ if ( mIMFContext )
+ {
+ ecore_imf_context_reset( mIMFContext );
+ }
+}
+
+Ecore_IMF_Context* ImfManager::GetContext()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetContext\n" );
+
+ return mIMFContext;
+}
+
+bool ImfManager::RestoreAfterFocusLost() const
+{
+ return mRestoreAfterFocusLost;
+}
+
+void ImfManager::SetRestoreAferFocusLost( bool toggle )
+{
+ mRestoreAfterFocusLost = toggle;
+}
+
+/**
+ * Called when an IMF Pre-Edit changed event is received.
+ * We are still predicting what the user is typing. The latest string is what the IMF module thinks
+ * the user wants to type.
+ */
+void ImfManager::PreEditChanged( void *, Ecore_IMF_Context *imfContext, void *event_info )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::PreEditChanged\n" );
+
+ char *preEditString( NULL );
+ int cursorPosition( 0 );
+ Eina_List *attrs = NULL;
+ Eina_List *l = NULL;
+
+ Ecore_IMF_Preedit_Attr *attr;
+
+ // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.
+ // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.
+ ecore_imf_context_preedit_string_with_attributes_get( imfContext, &preEditString, &attrs, &cursorPosition );
+
+ if ( attrs )
+ {
+ // iterate through the list of attributes getting the type, start and end position.
+ for ( l = attrs, (attr = (Ecore_IMF_Preedit_Attr*)eina_list_data_get(l) ); l; l = eina_list_next(l), ( attr = (Ecore_IMF_Preedit_Attr*)eina_list_data_get(l) ))
+ {
+ if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF)
+ {
+ // check first byte so know how many bytes a character is represented by as keyboard returns cursor position in bytes. Which is different for some languages.
+
+ size_t visualCharacterIndex = 0;
+ size_t byteIndex = 0;
+
+ // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
+ while ( preEditString[byteIndex] != '\0' )
+ {
+ // attr->end_index is provided as a byte position not character and we need to know the character position.
+ size_t currentSequenceLength = Utf8SequenceLength(preEditString[byteIndex]); // returns number of bytes used to represent character.
+ if ( byteIndex == attr->end_index )
+ {
+ cursorPosition = visualCharacterIndex;
+ break;
+ // end loop as found cursor position that matches byte position
+ }
+ else
+ {
+ byteIndex += currentSequenceLength; // jump to next character
+ visualCharacterIndex++; // increment character count so we know our position for when we get a match
+ }
+
+ DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString ));
+ }
+ }
+ }
+ }
+
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ std::string keyString ( preEditString );
+ int numberOfChars( 0 );
+
+ Dali::ImfManager handle( this );
+ Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::PREEDIT, keyString, cursorPosition, numberOfChars );
+ Dali::ImfManager::ImfCallbackData callbackData = mEventSignalV2.Emit( handle, imfEventData );
+
+ if ( callbackData.update )
+ {
+ SetCursorPosition( callbackData.cursorPosition );
+ SetSurroundingText( callbackData.currentText );
+
+ NotifyCursorPosition();
+ }
+
+ if ( callbackData.preeditResetRequired )
+ {
+ Reset();
+ }
+ }
+ free( preEditString );
+}
+
+void ImfManager::CommitReceived( void *, Ecore_IMF_Context *imfContext, void *event_info )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CommitReceived\n" );
+
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ const std::string keyString( (char *)event_info );
+ const int cursorOffset( 0 );
+ const int numberOfChars( 0 );
+
+ Dali::ImfManager handle( this );
+ Dali::ImfManager::ImfEventData imfEventData ( Dali::ImfManager::COMMIT, keyString, cursorOffset, numberOfChars );
+ Dali::ImfManager::ImfCallbackData callbackData = mEventSignalV2.Emit( handle, imfEventData );
+
+ if ( callbackData.update )
+ {
+ SetCursorPosition( callbackData.cursorPosition );
+ SetSurroundingText( callbackData.currentText );
+
+ NotifyCursorPosition();
+ }
+ }
+}
+
+/**
+ * Called when an IMF retrieve surround event is received.
+ * Here the IMF module wishes to know the string we are working with and where within the string the cursor is
+ * We need to signal the application to tell us this information.
+ */
+Eina_Bool ImfManager::RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::RetrieveSurrounding\n" );
+
+ std::string keyString ( "" );
+ int cursorOffset( 0 );
+ int numberOfChars( 0 );
+
+ Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::GETSURROUNDING , keyString, cursorOffset, numberOfChars );
+ Dali::ImfManager handle( this );
+ mEventSignalV2.Emit( handle, imfData );
+
+ if ( text )
+ {
+ std::string surroundingText( GetSurroundingText() );
+
+ if ( !surroundingText.empty() )
+ {
+ *text = strdup( surroundingText.c_str() );
+ }
+ else
+ {
+ *text = strdup( "" );
+ }
+ }
+
+ if ( cursorPosition )
+ {
+ *cursorPosition = GetCursorPosition();
+ }
+
+
+ return EINA_TRUE;
+}
+
+/**
+ * Called when an IMF delete surrounding event is received.
+ * Here we tell the application that it should delete a certain range.
+ */
+void ImfManager::DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteSurrounding\n" );
+
+ if ( Dali::Adaptor::IsAvailable() )
+ {
+ Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = (Ecore_IMF_Event_Delete_Surrounding*) event_info;
+
+ const std::string keyString( "" );
+ const int cursorOffset( deleteSurroundingEvent->offset );
+ const int numberOfChars( deleteSurroundingEvent->n_chars );
+
+ Dali::ImfManager::ImfEventData imfData ( Dali::ImfManager::DELETESURROUNDING , keyString, cursorOffset, numberOfChars );
+ Dali::ImfManager handle( this );
+ mEventSignalV2.Emit( handle, imfData );
+ }
+}
+
+void ImfManager::NotifyCursorPosition()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::NotifyCursorPosition\n" );
+
+ if ( mIMFContext )
+ {
+ ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
+ }
+}
+
+int ImfManager::GetCursorPosition()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetCursorPosition\n" );
+
+ return mIMFCursorPosition;
+}
+
+void ImfManager::SetCursorPosition( unsigned int cursorPosition )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetCursorPosition\n" );
+
+ mIMFCursorPosition = ( int )cursorPosition;
+}
+
+void ImfManager::SetSurroundingText( std::string text )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetSurroundingText\n" );
+
+ mSurroundingText = text;
+}
+
+std::string ImfManager::GetSurroundingText()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetSurroundingText\n" );
+
+ return mSurroundingText;
+}
+
+} // Adaptor
+
+} // Internal
+
+} // Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_IMF_MANAGER_H
+#define __DALI_INTERNAL_IMF_MANAGER_H
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <Ecore_IMF.h>
+#include <Ecore_X.h>
+
+#include <dali/public-api/object/base-object.h>
+#include <imf-manager.h>
+#include <dali/integration-api/events/key-event-integ.h>
+
+// INTERNAL INCLUDES
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class RenderSurface;
+
+class ImfManager : public Dali::BaseObject
+{
+public:
+ typedef Dali::ImfManager::ImfManagerSignalV2 ImfManagerSignalV2;
+ typedef Dali::ImfManager::ImfEventSignalV2 ImfEventSignalV2;
+
+public:
+
+ /**
+ * Create the IMF manager.
+ */
+ static Dali::ImfManager Get();
+
+ /**
+ * Constructor
+ * @param[in] ecoreXwin, The window is created by application.
+ */
+ ImfManager( Ecore_X_Window ecoreXwin );
+
+ /**
+ * Connect Callbacks required for IMF.
+ * If you don't connect imf callbacks, you can't get the key events.
+ * The events are PreeditChanged, Commit and DeleteSurrounding.
+ */
+ void ConnectCallbacks();
+
+ /**
+ * Disconnect Callbacks attached to imf context.
+ */
+ void DisconnectCallbacks();
+
+ /**
+ * @copydoc Dali::ImfManager::Activate()
+ */
+ void Activate();
+
+ /**
+ * @copydoc Dali::ImfManager::Deactivate()
+ */
+ void Deactivate();
+
+ /**
+ * @copydoc Dali::ImfManager::Reset()
+ */
+ void Reset();
+
+ /**
+ * @copydoc Dali::ImfManager::GetContext()
+ */
+ Ecore_IMF_Context* GetContext();
+
+ /**
+ * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
+ */
+ bool RestoreAfterFocusLost() const;
+
+ /**
+ * @copydoc Dali::ImfManager::SetRestoreAferFocusLost()
+ */
+ void SetRestoreAferFocusLost( bool toggle );
+
+ /**
+ * @copydoc Dali::ImfManager::PreEditChanged()
+ */
+ void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
+
+ /**
+ * @copydoc Dali::ImfManager::NotifyCursorPosition()
+ */
+ void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
+
+ /**
+ * @copydoc Dali::ImfManager::NotifyCursorPosition()
+ */
+ Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
+
+ /**
+ * @copydoc Dali::ImfManager::DeleteSurrounding()
+ */
+ void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
+
+ // Cursor related
+ /**
+ * @copydoc Dali::ImfManager::NotifyCursorPosition()
+ */
+ void NotifyCursorPosition();
+
+ /**
+ * @copydoc Dali::ImfManager::GetCursorPosition()
+ */
+ int GetCursorPosition();
+
+ /**
+ * @copydoc Dali::ImfManager::SetCursorPosition()
+ */
+ void SetCursorPosition( unsigned int cursorPosition );
+
+ /**
+ * @copydoc Dali::ImfManager::SetSurroundingText()
+ */
+ void SetSurroundingText( std::string text );
+
+ /**
+ * @copydoc Dali::ImfManager::GetSurroundingText()
+ */
+ std::string GetSurroundingText();
+
+public: // Signals
+
+ /**
+ * @copydoc Dali::ImfManager::ActivatedSignal()
+ */
+ ImfManagerSignalV2& ActivatedSignal() { return mActivatedSignalV2; }
+
+ /**
+ * @copydoc Dali::ImfManager::EventReceivedSignal()
+ */
+ ImfEventSignalV2& EventReceivedSignal() { return mEventSignalV2; }
+
+protected:
+
+ /**
+ * Destructor.
+ */
+ virtual ~ImfManager();
+
+private:
+ /**
+ * Context created the first time and kept until deleted.
+ * @param[in] ecoreXwin, The window is created by application.
+ */
+ void CreateContext( Ecore_X_Window ecoreXwin );
+
+ /**
+ * @copydoc Dali::ImfManager::DeleteContext()
+ */
+ void DeleteContext();
+
+private:
+ // Undefined
+ ImfManager( const ImfManager& );
+ ImfManager& operator=( ImfManager& );
+
+private:
+ Ecore_IMF_Context* mIMFContext;
+ int mIMFCursorPosition;
+ std::string mSurroundingText;
+
+ bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
+ bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
+
+ std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
+
+ ImfManagerSignalV2 mActivatedSignalV2;
+ ImfEventSignalV2 mEventSignalV2;
+
+public:
+
+inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
+{
+ DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
+
+ BaseObject& handle = imfManager.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::ImfManager&>(handle);
+}
+
+inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
+{
+ DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
+
+ const BaseObject& handle = imfManager.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::ImfManager&>(handle);
+}
+
+};
+
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_IMF_MANAGER_H
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "key-impl.h"
+
+// EXTERNAL INCLUDES
+#include <utilX.h>
+#include <map>
+#include <string.h>
+#include <iostream>
+
+
+#include <dali/integration-api/debug.h>
+
+
+namespace Dali
+{
+
+const KEY DALI_KEY_INVALID = -1;
+const KEY DALI_KEY_ESCAPE = 9;
+const KEY DALI_KEY_BACK = 166;
+const KEY DALI_KEY_CAMERA = 167;
+const KEY DALI_KEY_CONFIG = 168;
+const KEY DALI_KEY_POWER = 169;
+const KEY DALI_KEY_PAUSE = 170;
+const KEY DALI_KEY_CANCEL = 171;
+const KEY DALI_KEY_PLAY_CD = 172;
+const KEY DALI_KEY_STOP_CD = 173;
+const KEY DALI_KEY_PAUSE_CD = 174;
+const KEY DALI_KEY_NEXT_SONG = 175;
+const KEY DALI_KEY_PREVIOUS_SONG = 176;
+const KEY DALI_KEY_REWIND = 177;
+const KEY DALI_KEY_FASTFORWARD = 178;
+const KEY DALI_KEY_MEDIA = 179;
+const KEY DALI_KEY_PLAY_PAUSE = 180;
+const KEY DALI_KEY_MUTE = 181;
+const KEY DALI_KEY_SEND = 182;
+const KEY DALI_KEY_SELECT = 183;
+const KEY DALI_KEY_END = DALI_KEY_BACK;
+const KEY DALI_KEY_MENU = DALI_KEY_SEND;
+const KEY DALI_KEY_HOME = DALI_KEY_SELECT;
+const KEY DALI_KEY_HOMEPAGE = 187;
+const KEY DALI_KEY_WEBPAGE = 188;
+const KEY DALI_KEY_MAIL = 189;
+const KEY DALI_KEY_SCREENSAVER = 190;
+const KEY DALI_KEY_BRIGHTNESS_UP = 191;
+const KEY DALI_KEY_BRIGHTNESS_DOWN = 192;
+const KEY DALI_KEY_SOFT_KBD = 193;
+const KEY DALI_KEY_QUICK_PANEL = 194;
+const KEY DALI_KEY_TASK_SWITCH = 195;
+const KEY DALI_KEY_APPS = 196;
+const KEY DALI_KEY_SEARCH = 197;
+const KEY DALI_KEY_VOICE = 198;
+const KEY DALI_KEY_LANGUAGE = 199;
+const KEY DALI_KEY_VOLUME_UP = 200;
+const KEY DALI_KEY_VOLUME_DOWN = 201;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace KeyLookup
+{
+
+namespace
+{
+
+struct KeyLookup
+{
+ const char* keyName; ///< X string representation
+ const int daliKeyCode; ///< Dali Enum Representation
+ const bool deviceButton; ///< Whether the key is from a button on the device
+};
+
+// matches a DALI_KEY enum, to a X key name
+KeyLookup KeyLookupTable[]=
+{
+ // more than one key name can be assigned to a single dali-key code
+ // e.g. Menu and KEY_MENU("FS86KeyMenu") are both assigned to DALI_KEY_MENU
+
+ { "Escape", DALI_KEY_ESCAPE, false }, // item not defined in utilX
+ { "Menu", DALI_KEY_MENU, false }, // item not defined in utilX
+ { KEY_CAMERA, DALI_KEY_CAMERA, false },
+ { KEY_CONFIG, DALI_KEY_CONFIG, false },
+ { KEY_POWER, DALI_KEY_POWER, true },
+ { KEY_PAUSE, DALI_KEY_PAUSE, false },
+ { KEY_CANCEL, DALI_KEY_CANCEL, false },
+ { KEY_PLAYCD, DALI_KEY_PLAY_CD, false },
+ { KEY_STOPCD, DALI_KEY_STOP_CD, false },
+ { KEY_PAUSECD, DALI_KEY_PAUSE_CD, false },
+ { KEY_NEXTSONG, DALI_KEY_NEXT_SONG, false },
+ { KEY_PREVIOUSSONG, DALI_KEY_PREVIOUS_SONG, false },
+ { KEY_REWIND, DALI_KEY_REWIND, false },
+ { KEY_FASTFORWARD, DALI_KEY_FASTFORWARD, false },
+ { KEY_MEDIA, DALI_KEY_MEDIA, false },
+ { KEY_PLAYPAUSE, DALI_KEY_PLAY_PAUSE, false },
+ { KEY_MUTE, DALI_KEY_MUTE, false },
+ { KEY_SEND, DALI_KEY_SEND, true },
+ { KEY_SELECT, DALI_KEY_SELECT, true },
+ { KEY_END, DALI_KEY_END, true },
+ { KEY_MENU, DALI_KEY_MENU, true },
+ { KEY_HOME, DALI_KEY_HOME, true },
+ { KEY_BACK, DALI_KEY_BACK, true },
+ { KEY_HOMEPAGE, DALI_KEY_HOMEPAGE, false },
+ { KEY_WEBPAGE, DALI_KEY_WEBPAGE, false },
+ { KEY_MAIL, DALI_KEY_MAIL, false },
+ { KEY_SCREENSAVER, DALI_KEY_SCREENSAVER, false },
+ { KEY_BRIGHTNESSUP, DALI_KEY_BRIGHTNESS_UP, false },
+ { KEY_BRIGHTNESSDOWN, DALI_KEY_BRIGHTNESS_DOWN, false },
+ { KEY_SOFTKBD, DALI_KEY_SOFT_KBD, false },
+ { KEY_QUICKPANEL, DALI_KEY_QUICK_PANEL, false },
+ { KEY_TASKSWITCH, DALI_KEY_TASK_SWITCH, false },
+ { KEY_APPS, DALI_KEY_APPS, false },
+ { KEY_SEARCH, DALI_KEY_SEARCH, false },
+ { KEY_VOICE, DALI_KEY_VOICE, false },
+ { KEY_LANGUAGE, DALI_KEY_LANGUAGE, false },
+ { KEY_VOLUMEUP, DALI_KEY_VOLUME_UP, true },
+ { KEY_VOLUMEDOWN, DALI_KEY_VOLUME_DOWN, true },
+};
+
+const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable))/ (sizeof(KeyLookup));
+
+class KeyMap
+{
+ public:
+
+ KeyMap():
+ mLookup( cmpString )
+ {
+ // create the lookup
+ for( size_t i = 0; i < KEY_LOOKUP_COUNT ; ++i )
+ {
+ const KeyLookup& keyLookup( KeyLookupTable[i] );
+ mLookup[ keyLookup.keyName ] = DaliKeyType( keyLookup.daliKeyCode, keyLookup.deviceButton );
+ }
+ }
+
+ int GetDaliKeyEnum( const char* keyName ) const
+ {
+ Lookup::const_iterator i = mLookup.find( keyName );
+ if( i == mLookup.end() )
+ {
+ return -1;
+ }
+ else
+ {
+ return (*i).second.first;
+ }
+ }
+
+ bool IsDeviceButton( const char* keyName ) const
+ {
+ Lookup::const_iterator i = mLookup.find( keyName );
+ if ( i != mLookup.end() )
+ {
+ return (*i).second.second;
+ }
+ return false;
+ }
+
+ private:
+
+ /**
+ * compare function, to compare string by pointer
+ */
+ static bool cmpString( const char* a, const char* b)
+ {
+ return strcmp(a, b) < 0;
+ }
+
+ typedef std::pair< int, bool > DaliKeyType;
+ typedef std::map<const char* /* key name */, DaliKeyType /* key code */, bool(*) ( char const* a, char const* b) > Lookup;
+ Lookup mLookup;
+
+};
+const KeyMap globalKeyLookup;
+
+} // un-named name space
+
+bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey)
+{
+ int key = globalKeyLookup.GetDaliKeyEnum( keyEvent.keyPressedName.c_str() );
+ return daliKey == key;
+}
+
+bool IsDeviceButton( const char* keyName )
+{
+ return globalKeyLookup.IsDeviceButton( keyName );
+}
+
+} // namespace KeyLookup
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "pixmap-image-impl.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore_X.h>
+#include <X11/Xutil.h>
+#include <dali/integration-api/debug.h>
+#include <render-surface.h>
+
+// INTERNAL INCLUDES
+#include <gl/egl-image-extensions.h>
+#include <gl/egl-factory.h>
+#include <adaptor-impl.h>
+
+// Allow this to be encoded and saved:
+#include <platform-abstractions/slp/resource-loader/resource-loader.h>
+#include <platform-abstractions/slp/resource-loader/loader-jpeg.h>
+#include <platform-abstractions/slp/resource-loader/loader-png.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+using Dali::Integration::PixelBuffer;
+
+// Pieces needed to save compressed images (temporary location while plumbing):
+namespace
+{
+
+ /**
+ * Free an allocated XImage on destruction.
+ */
+ struct XImageJanitor
+ {
+ XImageJanitor( XImage* const pXImage ) : mXImage( pXImage )
+ {
+ DALI_ASSERT_DEBUG(pXImage != 0 && "Null pointer to XImage.");
+ }
+
+ ~XImageJanitor()
+ {
+ if( mXImage )
+ {
+ if( !XDestroyImage(mXImage) )
+ {
+ DALI_ASSERT_DEBUG("XImage deallocation failure");
+ }
+ }
+ }
+ XImage* const mXImage;
+ private:
+ XImageJanitor( const XImageJanitor& rhs );
+ XImageJanitor& operator = ( const XImageJanitor& rhs );
+ };
+
+ /**
+ * Simple function to tell intended image file format from filename
+ */
+ FileFormat GetFormatFromFileName( const std::string& filename )
+ {
+ if (filename.length() < 5)
+ {
+ DALI_LOG_WARNING("Invalid (short) filename.");
+ }
+ FileFormat format(INVALID_FORMAT);
+
+ const std::size_t filenameSize = filename.length();
+
+ if(filenameSize >= 4){ // Avoid throwing out_of_range or failing silently if exceptions are turned-off on the compare(). (http://www.cplusplus.com/reference/string/string/compare/)
+ if( !filename.compare( filenameSize - 4, 4, ".jpg" )
+ || !filename.compare( filenameSize - 4, 4, ".JPG" ) )
+ {
+ format = JPG_FORMAT;
+ }
+ else if( !filename.compare( filenameSize - 4, 4, ".png" )
+ || !filename.compare( filenameSize - 4, 4, ".PNG" ) )
+ {
+ format = PNG_FORMAT;
+ }
+ else if( !filename.compare( filenameSize - 4, 4, ".bmp" )
+ || !filename.compare( filenameSize - 4, 4, ".BMP" ) )
+ {
+ format = BMP_FORMAT;
+ }
+ else if( !filename.compare( filenameSize - 4, 4, ".gif" )
+ || !filename.compare( filenameSize - 4, 4, ".GIF" ) )
+ {
+ format = GIF_FORMAT;
+ }
+ else if( !filename.compare( filenameSize - 4, 4, ".ico" )
+ || !filename.compare( filenameSize - 4, 4, ".ICO" ) )
+ {
+ format = ICO_FORMAT;
+ }
+ else if(filenameSize >= 5){
+ if( !filename.compare( filenameSize - 5, 5, ".jpeg" )
+ || !filename.compare( filenameSize - 5, 5, ".JPEG" ) )
+ {
+ format = JPG_FORMAT;
+ }
+ }
+ }
+
+ return format;
+ }
+
+ bool EncodeToFormat( const PixelBuffer* pixelBuffer, std::vector< unsigned char >& encodedPixels, FileFormat formatEncoding, std::size_t width, std::size_t height, Pixel::Format pixelFormat )
+ {
+ switch( formatEncoding )
+ {
+ case JPG_FORMAT:
+ {
+ return SlpPlatform::EncodeToJpeg( pixelBuffer, encodedPixels, width, height, pixelFormat );
+ break;
+ }
+ case PNG_FORMAT:
+ {
+ return SlpPlatform::EncodeToPng( pixelBuffer, encodedPixels, width, height, pixelFormat );
+ break;
+ }
+ default:
+ {
+ DALI_LOG_ERROR("Format not supported for image encoding (supported formats are PNG and JPEG)");
+ break;
+ }
+ }
+ return false;
+ }
+
+ bool EncodeToFile(const PixelBuffer * const pixelBuffer, const std::string& filename, const Pixel::Format pixelFormat, const std::size_t width, const std::size_t height)
+ {
+ DALI_ASSERT_DEBUG(pixelBuffer != 0 && filename.size() > 4 && width > 0 && height > 0);
+ std::vector< unsigned char > pixbufEncoded;
+ const FileFormat format = GetFormatFromFileName( filename );
+ const bool encodeResult = EncodeToFormat( pixelBuffer, pixbufEncoded, format, width, height, pixelFormat );
+ if(!encodeResult)
+ {
+ DALI_LOG_ERROR("Encoding pixels failed");
+ return false;
+ }
+ return SlpPlatform::ResourceLoader::SaveFile( filename, pixbufEncoded );
+ }
+}
+
+PixmapImage* PixmapImage::New(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Dali::Adaptor& adaptor, Any pixmap )
+{
+ PixmapImage* image = new PixmapImage( width, height, depth, adaptor, pixmap );
+ DALI_ASSERT_DEBUG( image && "PixmapImage allocation failed." );
+
+ // 2nd phase construction
+ if(image) //< Defensive in case we ever compile without exceptions.
+ {
+ image->Initialize();
+ }
+
+ return image;
+}
+
+PixmapImage::PixmapImage(unsigned int width, unsigned int height, Dali::PixmapImage::ColorDepth depth, Dali::Adaptor& adaptor, Any pixmap)
+: mWidth(width),
+ mHeight(height),
+ mOwnPixmap(true),
+ mPixmap(0),
+ mDisplay(NULL),
+ mPixelFormat(Pixel::RGB888),
+ mColorDepth(depth),
+ mAdaptor(Internal::Adaptor::Adaptor::GetImplementation(adaptor)),
+ mEglImageKHR(NULL)
+{
+ // assign the pixmap
+ mPixmap = GetPixmapFromAny(pixmap);
+}
+
+void PixmapImage::Initialize()
+{
+ // Get render-surface being used by Dali
+ Dali::RenderSurface& surface = mAdaptor.GetSurface();
+
+ // get the X11 display pointer and store it
+ // it is used by eglCreateImageKHR, and XFreePixmap
+ // Any other display (x-connection) will fail in eglCreateImageKHR
+ Any display = surface.GetDisplay();
+
+ // the dali display pointer is needed
+ mDisplay = AnyCast<Ecore_X_Display*>(display);
+
+ // if pixmap has been created outside of X11 Image we can return
+ if (mPixmap)
+ {
+ // we don't own the pixmap
+ mOwnPixmap = false;
+
+ // find out the pixmap width / height and color depth
+ GetPixmapDetails();
+ return;
+ }
+
+ // get the pixel depth
+ int depth = GetPixelDepth(mColorDepth);
+
+ // set the pixel format
+ SetPixelFormat(depth);
+
+ // Get the X-Renderable for which the pixmap is created on
+ Any renderableSurface = surface.GetSurface();
+
+ // if Dali is using a Pixmap or Window to render to it doesn't matter because they have the same
+ // underlying type of unsigned long
+ Ecore_X_Window daliWindow = AnyCast< Ecore_X_Window >(renderableSurface);
+
+ mPixmap = ecore_x_pixmap_new(daliWindow, mWidth, mHeight, depth);
+ ecore_x_sync();
+}
+
+PixmapImage::~PixmapImage()
+{
+ // Lost the opportunity to call GlExtensionDestroy() if Adaptor is destroyed first
+ if( Adaptor::IsAvailable() )
+ {
+ // GlExtensionDestroy() called from GLCleanup on the render thread. Checking this is done here.
+ // (mEglImageKHR is now read/written from different threads although ref counted destruction
+ // should mean this isnt concurrent)
+ DALI_ASSERT_ALWAYS( NULL == mEglImageKHR && "NativeImage GL resources have not been properly cleaned up" );
+ }
+
+ if (mOwnPixmap && mPixmap)
+ {
+ ecore_x_pixmap_free(mPixmap);
+ }
+}
+
+Any PixmapImage::GetPixmap(Dali::PixmapImage::PixmapAPI api) const
+{
+ if (api == Dali::PixmapImage::ECORE_X11)
+ {
+ // return ecore x11 type
+ return Any(mPixmap);
+ }
+ else
+ {
+ // return x11 type after casting it
+ Pixmap pixmap= static_cast<Pixmap>(mPixmap);
+ return Any(pixmap);
+ }
+}
+
+Any PixmapImage::GetDisplay() const
+{
+ // return ecore x11 type
+ return Any(mDisplay);
+}
+
+bool PixmapImage::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
+{
+ DALI_ASSERT_DEBUG(sizeof(unsigned) == 4);
+ bool success = false;
+ width = mWidth;
+ height = mHeight;
+
+ XImageJanitor xImageJanitor( XGetImage(static_cast<Display*>(mDisplay),
+ mPixmap,
+ 0, 0, // x,y of subregion to extract.
+ width, height, // of suregion to extract.
+ 0xFFFFFFFF,
+ ZPixmap));
+ XImage* const pXImage = xImageJanitor.mXImage;
+ DALI_ASSERT_DEBUG(pXImage && "XImage (from pixmap) could not be retrieved from the server");
+ if(!pXImage)
+ {
+ DALI_LOG_ERROR("Could not retrieve Ximage.");
+ }
+ else
+ {
+ switch(pXImage->depth)
+ {
+ // Note, depth is a logical value. On target the framebuffer is still 32bpp
+ // (see pXImage->bits_per_pixel) so we go through XGetPixel() and swizzle.
+ // Note, this could be the default, fallback case for all depths if *pXImage
+ // didn't have blank RGB masks (X bug), but we have to hardcode the masks and
+ // shifts instead.
+ case 24:
+ {
+ pixelFormat = Pixel::RGB888;
+ pixbuf.resize(width*height*3);
+ unsigned char* bufPtr = &pixbuf[0];
+
+ for(unsigned y = height-1; y < height; --y)
+ {
+ for(unsigned x = 0; x < width; ++x, bufPtr+=3)
+ {
+ const unsigned pixel = XGetPixel(pXImage,x,y);
+
+ // store as RGB
+ const unsigned blue = pixel & 0xFFU;
+ const unsigned green = (pixel >> 8) & 0xFFU;
+ const unsigned red = (pixel >> 16) & 0xFFU;
+
+ *bufPtr = red;
+ *(bufPtr+1) = green;
+ *(bufPtr+2) = blue;
+ }
+ }
+ success = true;
+ break;
+ }
+ case 32:
+ {
+ if(pXImage->data)
+ {
+ // Sweep through the image, doing a vertical flip, but handling each scanline as
+ // an inlined intrinsic/builtin memcpy (should be fast):
+ pixbuf.resize(width*height*4);
+ unsigned * bufPtr = reinterpret_cast<unsigned *>(&pixbuf[0]);
+ const unsigned xDataLineSkip = pXImage->bytes_per_line;
+ const size_t copy_count = width * 4;
+ pixelFormat = Pixel::BGRA8888;
+
+ for(unsigned y = height-1; y < height; --y, bufPtr += width)
+ {
+ const char * const in = pXImage->data + xDataLineSkip * y;
+
+ // Copy a whole scanline at a time:
+ DALI_ASSERT_DEBUG( size_t( bufPtr ) >= size_t( &pixbuf[0] ));
+ DALI_ASSERT_DEBUG( reinterpret_cast<size_t>( bufPtr ) + copy_count <= reinterpret_cast<size_t>( &pixbuf[pixbuf.size()] ) );
+ DALI_ASSERT_DEBUG( in >= pXImage->data );
+ DALI_ASSERT_DEBUG( in + copy_count <= pXImage->data + xDataLineSkip * height );
+ __builtin_memcpy( bufPtr, in, copy_count );
+ }
+ success = true;
+ }
+ else
+ {
+ DALI_LOG_ERROR("XImage has null data pointer.");
+ }
+ break;
+ }
+ // Make a case for 16 bit modes especially to remember that the only reason we don't support them is a bug in X:
+ case 16:
+ {
+ DALI_ASSERT_DEBUG(pXImage->red_mask && pXImage->green_mask && pXImage->blue_mask && "No image masks mean 16 bit modes are not possible.");
+ ///! If the above assert doesn't fail in a debug build, the X bug may have been fixed, so revisit this function.
+ ///! No break, fall through to the general unsupported format warning below.
+ }
+ default:
+ {
+ DALI_LOG_WARNING("Pixmap has unsupported bit-depth for getting pixels: %u", pXImage->depth);
+ }
+ }
+ }
+ if(!success)
+ {
+ DALI_LOG_ERROR("Failed to get pixels from PixmapImage.");
+ pixbuf.resize(0);
+ width = 0;
+ height = 0;
+ }
+ return success;
+}
+
+bool PixmapImage::EncodeToFile(const std::string& filename) const
+{
+ std::vector< unsigned char > pixbuf;
+ unsigned int width(0), height(0);
+ Pixel::Format pixelFormat;
+
+ if(GetPixels(pixbuf, width, height, pixelFormat))
+ {
+ return Dali::Internal::Adaptor::EncodeToFile(&pixbuf[0], filename, pixelFormat, width, height);
+ }
+ return false;
+}
+
+bool PixmapImage::GlExtensionCreate()
+{
+ // if the image existed previously delete it.
+ if (mEglImageKHR != NULL)
+ {
+ GlExtensionDestroy();
+ }
+
+ EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
+
+ // casting from an unsigned int to a void *, which should then be cast back
+ // to an unsigned int in the driver.
+ EGLClientBuffer eglBuffer = reinterpret_cast< EGLClientBuffer > (mPixmap);
+
+ mEglImageKHR = eglImageExtensions->CreateImageKHR( eglBuffer );
+
+ return mEglImageKHR != NULL;
+}
+
+void PixmapImage::GlExtensionDestroy()
+{
+ EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
+
+ eglImageExtensions->DestroyImageKHR(mEglImageKHR);
+
+ mEglImageKHR = NULL;
+}
+
+unsigned int PixmapImage::TargetTexture()
+{
+ EglImageExtensions* eglImageExtensions = GetEglImageExtensions();
+
+ eglImageExtensions->TargetTextureKHR(mEglImageKHR);
+
+ return 0;
+}
+
+int PixmapImage::GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const
+{
+ switch (depth)
+ {
+ case Dali::PixmapImage::COLOR_DEPTH_DEFAULT:
+ {
+ // Get the default screen depth
+ return ecore_x_default_depth_get(ecore_x_display_get(), ecore_x_default_screen_get());
+ }
+ case Dali::PixmapImage::COLOR_DEPTH_8:
+ {
+ return 8;
+ }
+ case Dali::PixmapImage::COLOR_DEPTH_16:
+ {
+ return 16;
+ }
+ case Dali::PixmapImage::COLOR_DEPTH_24:
+ {
+ return 24;
+ }
+ case Dali::PixmapImage::COLOR_DEPTH_32:
+ {
+ return 32;
+ }
+ default:
+ {
+ DALI_ASSERT_DEBUG(0 && "unknown color enum");
+ return 0;
+ }
+ }
+}
+
+void PixmapImage::SetPixelFormat(int depth)
+{
+ // store the pixel format based on the depth
+ switch (depth)
+ {
+ case 8:
+ {
+ mPixelFormat = Pixel::A8;
+ break;
+ }
+ case 16:
+ {
+ mPixelFormat = Pixel::RGB565;
+ break;
+ }
+ case 32:
+ {
+ mPixelFormat = Pixel::RGBA8888;
+ break;
+ }
+ case 24:
+ default:
+ {
+ mPixelFormat = Pixel::RGB888;
+ break;
+ }
+ }
+}
+
+Ecore_X_Pixmap PixmapImage::GetPixmapFromAny(Any pixmap) const
+{
+ if (pixmap.Empty())
+ {
+ return 0;
+ }
+
+ // see if it is of type x11 pixmap
+ if (pixmap.GetType() == typeid (Pixmap))
+ {
+ // get the x pixmap type
+ Pixmap xpixmap = AnyCast<Pixmap>(pixmap);
+
+ // cast it to a ecore pixmap type
+ return static_cast<Ecore_X_Pixmap>(xpixmap);
+ }
+ else
+ {
+ return AnyCast<Ecore_X_Pixmap>(pixmap);
+ }
+}
+
+void PixmapImage::GetPixmapDetails()
+{
+ int x, y;
+
+ // get the width, height and depth
+ ecore_x_pixmap_geometry_get(mPixmap, &x, &y, (int*)&mWidth, (int*)&mHeight);
+
+ // set the pixel format
+ SetPixelFormat(ecore_x_pixmap_depth_get(mPixmap));
+}
+
+EglImageExtensions* PixmapImage::GetEglImageExtensions() const
+{
+ EglFactory& factory = mAdaptor.GetEGLFactory();
+ EglImageExtensions* egl = factory.GetImageExtensions();
+ DALI_ASSERT_DEBUG( egl && "EGL Image Extensions not initialized" );
+ return egl;
+}
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_PIXMAP_IMAGE_H__
+#define __DALI_INTERNAL_PIXMAP_IMAGE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <Ecore_X.h>
+#include <pixmap-image.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class Adaptor;
+class EglImageExtensions;
+
+/**
+ * Dali internal PixmapImage.
+ */
+class PixmapImage
+{
+public:
+
+ /**
+ * Create a new PixmapImage internally.
+ * Depending on hardware the width and height may have to be a power of two.
+ * @param[in] width The width of the image.
+ * @param[in] height The height of the image.
+ * @param[in] depth color depth of the pixmap
+ * @param[in] adaptor reference to dali adaptor
+ * @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
+ * @return A smart-pointer to a newly allocated image.
+ */
+ static PixmapImage* New(unsigned int width,
+ unsigned int height,
+ Dali::PixmapImage::ColorDepth depth,
+ Dali::Adaptor& adaptor,
+ Any pixmap);
+
+ /**
+ * @copydoc Dali::PixmapImage::GetPixmap()
+ */
+ Any GetPixmap(Dali::PixmapImage::PixmapAPI api) const;
+
+ /**
+ * @copydoc Dali::PixmapImage::GetDisplay()
+ */
+ Any GetDisplay() const;
+
+ /**
+ * @copydoc Dali::PixmapImage::GetPixels()
+ */
+ bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
+
+ /**
+ * @copydoc Dali::PixmapImage::EncodeToFile(const std::string& )
+ */
+ bool EncodeToFile(const std::string& filename) const;
+
+ /**
+ * destructor
+ */
+ ~PixmapImage();
+
+ /**
+ * @copydoc Dali::PixmapImage::GlExtensionCreate()
+ */
+ bool GlExtensionCreate();
+
+ /**
+ * @copydoc Dali::PixmapImage::GlExtensionDestroy()
+ */
+ void GlExtensionDestroy();
+
+ /**
+ * @copydoc Dali::PixmapImage::TargetTexture()
+ */
+ unsigned int TargetTexture();
+
+ /**
+ * @copydoc Dali::PixmapImage::GetWidth()
+ */
+ unsigned int GetWidth() const
+ {
+ return mWidth;
+ }
+
+ /**
+ * @copydoc Dali::PixmapImage::GetHeight()
+ */
+ unsigned int GetHeight() const
+ {
+ return mHeight;
+ }
+
+ /**
+ * @copydoc Dali::PixmapImage::GetPixelFormat()
+ */
+ Pixel::Format GetPixelFormat() const
+ {
+ return mPixelFormat;
+ }
+
+private:
+
+ /**
+ * Private constructor; @see PixmapImage::New()
+ * @param[in] width The width of the image.
+ * @param[in] height The height of the image.
+ * @param[in] colour depth of the pixmap
+ * @param[in] adaptor a reference to Dali adaptor
+ * @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
+ */
+ PixmapImage(unsigned int width,
+ unsigned int height,
+ Dali::PixmapImage::ColorDepth depth,
+ Dali::Adaptor &adaptor,
+ Any pixmap);
+
+ /**
+ * 2nd phase construction.
+ */
+ void Initialize();
+
+ /**
+ * Uses X11 to get the default depth.
+ * @param depth the PixelImage depth enum
+ * @return default x11 pixel depth
+ */
+ int GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const;
+
+ /**
+ * Sets the pixel format based on the bit depth
+ * @param depth depth in bytes
+ */
+ void SetPixelFormat(int depth);
+
+ /**
+ * Gets the pixmap from the Any parameter
+ * @param pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
+ * @return pixmap x11 pixmap
+ */
+ Ecore_X_Pixmap GetPixmapFromAny(Any pixmap) const;
+
+ /**
+ * Given an existing pixmap, the function uses X to find out
+ * the width, heigth and depth of that pixmap.
+ */
+ void GetPixmapDetails();
+
+ /**
+ * Returns the egl image extensions class from the adaptor
+ * @return reference to egl image extensionsa
+ */
+ EglImageExtensions* GetEglImageExtensions() const;
+
+private:
+
+ unsigned int mWidth; ///< pixmap width
+ unsigned int mHeight; ///< pixmap heights
+ bool mOwnPixmap; ///< Whether we created pixmap or not
+ Ecore_X_Pixmap mPixmap; ///< From Xlib
+ Ecore_X_Display* mDisplay; ///< x-connection used to create pixmap (if it was not created outside of PixmapImage)
+ Pixel::Format mPixelFormat; ///< pixmap pixel format
+ Dali::PixmapImage::ColorDepth mColorDepth; ///< color depth of pixmap
+ Adaptor& mAdaptor; ///< adaptor
+ void* mEglImageKHR; ///< From EGL extension
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_PIXMAP_IMAGE_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "pixmap-render-surface.h"
+
+// EXTERNAL INCLUDES
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <X11/extensions/Xfixes.h> // for damage notify
+#include <X11/extensions/Xdamage.h> // for damage notify
+
+#include <dali/integration-api/gl-abstraction.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <ecore-x-types.h>
+#include <trigger-event.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+#if defined(DEBUG_ENABLED)
+extern Debug::Filter* gRenderSurfaceLogFilter;
+#endif
+
+namespace ECore
+{
+
+PixmapRenderSurface::PixmapRenderSurface( Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent)
+: RenderSurface( Dali::RenderSurface::PIXMAP, positionSize, surface, display, name, isTransparent )
+{
+ Init( surface );
+}
+
+PixmapRenderSurface::~PixmapRenderSurface()
+{
+ // release the surface if we own one
+ if( mOwnSurface )
+ {
+ // if we did create the pixmap, delete the pixmap
+ DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::General, "Own pixmap (%x) freed\n", mX11Pixmap );
+ ecore_x_pixmap_free( mX11Pixmap );
+ }
+}
+
+Ecore_X_Drawable PixmapRenderSurface::GetDrawable()
+{
+ return (Ecore_X_Drawable)mX11Pixmap;
+}
+
+Dali::RenderSurface::SurfaceType PixmapRenderSurface::GetType()
+{
+ return Dali::RenderSurface::PIXMAP;
+}
+
+Any PixmapRenderSurface::GetSurface()
+{
+ return Any( mX11Pixmap );
+}
+
+void PixmapRenderSurface::InitializeEgl( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+ eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
+
+ eglImpl.ChooseConfig(false, mColorDepth);
+}
+
+void PixmapRenderSurface::CreateEglSurface( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+
+ // create the EGL surface
+ // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
+ XPixmap pixmap = static_cast< XPixmap>( mX11Pixmap );
+ eglImpl.CreateSurfacePixmap( (EGLNativePixmapType)pixmap, mColorDepth ); // reinterpret_cast does not compile
+}
+
+void PixmapRenderSurface::DestroyEglSurface( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+ eglImpl.DestroySurface();
+}
+
+bool PixmapRenderSurface::ReplaceEGLSurface( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+ eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
+
+ // a new surface for the new pixmap
+ // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
+ XPixmap pixmap = static_cast< XPixmap>( mX11Pixmap );
+ return eglImpl.ReplaceSurfacePixmap( (EGLNativePixmapType)pixmap, // reinterpret_cast does not compile
+ reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
+}
+
+bool PixmapRenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& )
+{
+ // nothing to do for pixmaps
+ return true;
+}
+
+void PixmapRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode )
+{
+ // flush gl instruction queue
+ glAbstraction.Flush();
+
+ // create damage for client applications which wish to know the update timing
+ if( mRenderNotification )
+ {
+ // use notification trigger
+ // Tell the event-thread to render the pixmap
+ mRenderNotification->Trigger();
+ }
+ else
+ {
+ // as a fallback, send damage event. This is needed until livebox is fixed to
+ // stop using damage events for render
+ Ecore_X_Drawable drawable = GetDrawable();
+
+ if( drawable )
+ {
+ XRectangle rect;
+ XserverRegion region;
+
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = mPosition.width;
+ rect.height = mPosition.height;
+
+ // make a fixes region as updated area
+ region = XFixesCreateRegion( mMainDisplay, &rect, 1 );
+ // add damage event to updated drawable
+ XDamageAdd( mMainDisplay, (Drawable)drawable, region );
+ XFixesDestroyRegion( mMainDisplay, region );
+
+ XFlush( mMainDisplay );
+ }
+ }
+
+ // Do render synchronisation
+ DoRenderSync( timeDelta, syncMode );
+}
+
+void PixmapRenderSurface::CreateXRenderable()
+{
+ // check we're creating one with a valid size
+ DALI_ASSERT_ALWAYS( mPosition.width > 0 && mPosition.height > 0 && "Pixmap size is invalid" );
+
+ // create the pixmap
+ mX11Pixmap = ecore_x_pixmap_new(0, mPosition.width, mPosition.height, mColorDepth);
+
+ // clear the pixmap
+ unsigned int foreground;
+ Ecore_X_GC gc;
+ foreground = 0;
+ gc = ecore_x_gc_new( mX11Pixmap,
+ ECORE_X_GC_VALUE_MASK_FOREGROUND,
+ &foreground );
+ ecore_x_drawable_rectangle_fill( mX11Pixmap, gc, 0, 0, mPosition.width, mPosition.height );
+
+ DALI_ASSERT_ALWAYS( mX11Pixmap && "Failed to create X pixmap" );
+
+ // we SHOULD guarantee the xpixmap/x11 window was created in x server.
+ ecore_x_sync();
+
+ ecore_x_gc_free(gc);
+}
+
+void PixmapRenderSurface::UseExistingRenderable( unsigned int surfaceId )
+{
+ mX11Pixmap = static_cast< Ecore_X_Pixmap >( surfaceId );
+}
+
+void PixmapRenderSurface::RenderSync()
+{
+ {
+ boost::unique_lock< boost::mutex > lock( mSyncMutex );
+ mSyncReceived = true;
+ }
+
+ // wake render thread if it was waiting for the notify
+ mSyncNotify.notify_all();
+}
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ECORE_X_PIXMAP_RENDER_SURFACE_H__
+#define __DALI_INTERNAL_ECORE_X_PIXMAP_RENDER_SURFACE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <ecore-x-render-surface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class TriggerEvent;
+
+namespace ECore
+{
+
+/**
+ * Ecore X11 implementation of render surface.
+ */
+class PixmapRenderSurface : public RenderSurface
+{
+public:
+
+ /**
+ * Uses an X11 surface to render to.
+ * @param [in] positionSize the position and size of the surface
+ * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
+ * @param [in] display connection to X-server if the surface is a X window or pixmap (type must be void * to X display struct)
+ * @param [in] name optional name of surface passed in
+ * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
+ */
+ PixmapRenderSurface( Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent = false);
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface::~RenderSurface
+ */
+ virtual ~PixmapRenderSurface();
+
+public: // API
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface::GetDrawable()
+ */
+ virtual Ecore_X_Drawable GetDrawable();
+
+public: // from Dali::RenderSurface
+
+ /**
+ * @copydoc Dali::RenderSurface::GetType()
+ */
+ virtual Dali::RenderSurface::SurfaceType GetType();
+
+ /**
+ * @copydoc Dali::RenderSurface::GetSurface()
+ */
+ virtual Any GetSurface();
+
+public: // from Internal::Adaptor::RenderSurface
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::InitializeEgl()
+ */
+ virtual void InitializeEgl( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface()
+ */
+ virtual void CreateEglSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface()
+ */
+ virtual void DestroyEglSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface()
+ */
+ virtual bool ReplaceEGLSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::RenderSync()
+ */
+ virtual void RenderSync();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::PreRender()
+ */
+ virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::PostRender()
+ */
+ virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode );
+
+private:
+
+ /**
+ * Create XPixmap
+ */
+ virtual void CreateXRenderable();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface::UseExistingRenderable
+ */
+ virtual void UseExistingRenderable( unsigned int surfaceId );
+
+private: // Data
+
+ Ecore_X_Pixmap mX11Pixmap; ///< X-Pixmap
+
+};
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ECORE_X_PIXMAP_RENDER_SURFACE_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "server-connection.h"
+
+// EXTERNAL INCLUDES
+#include <Ecore.h>
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+#if defined(DEBUG_ENABLED)
+extern Debug::Filter* gIndicatorLogFilter;
+#endif
+
+
+ServerConnection::ServerConnection(
+ const char* serviceName,
+ int serviceNumber,
+ bool isSystem,
+ ServerConnection::Observer* observer)
+
+: mConnected(false),
+ mObserver(observer)
+{
+ Ecore_Ipc_Type ipctype = ECORE_IPC_LOCAL_USER;
+
+ ecore_ipc_init();
+ mService.name = eina_stringshare_add(serviceName);
+ mService.num = serviceNumber;
+ mService.isSystem = isSystem;
+
+ if (mService.isSystem)
+ {
+ ipctype = ECORE_IPC_LOCAL_SYSTEM;
+ }
+
+ DALI_LOG_INFO( gIndicatorLogFilter, Debug::General, "ServerConnection: Connecting to %s %d\n", mService.name, mService.num );
+
+ mIpcServer = ecore_ipc_server_connect( ipctype, (char *)mService.name, mService.num, this );
+
+ if( !mIpcServer )
+ {
+ ecore_ipc_shutdown();
+ }
+ else
+ {
+ mIpcHandlers.push_back( ecore_event_handler_add( ECORE_IPC_EVENT_SERVER_ADD,
+ &ServerConnection::IpcServerAdd,
+ this ) );
+
+ mIpcHandlers.push_back( ecore_event_handler_add( ECORE_IPC_EVENT_SERVER_DEL,
+ &ServerConnection::IpcServerDel,
+ this ) );
+
+ mIpcHandlers.push_back( ecore_event_handler_add( ECORE_IPC_EVENT_SERVER_DATA,
+ &ServerConnection::IpcServerData,
+ this));
+
+ mConnected = true;
+ }
+}
+
+} // Adaptor
+} // Internal
+} // Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <system_settings.h>
+#include <Elementary.h>
+
+// INTERNAL INCLUDES
+#include "system-settings.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+int GetElmAccessActionOver()
+{
+ // ELM_ACCESS_ACTION_OVER not available in common profile
+ return ELM_ACCESS_ACTION_LAST;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "virtual-keyboard-impl.h"
+
+// EXTERNAL INCLUDES
+#include <X11/Xlib.h>
+#include <Ecore_X.h>
+#include <algorithm>
+
+#include <dali/public-api/common/vector-wrapper.h>
+#include <adaptor.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <locale-utils.h>
+#include <imf-manager-impl.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace VirtualKeyboard
+{
+
+void RotateTo(int angle)
+{
+ // Get focus window used by Keyboard and rotate it
+ Display* display = XOpenDisplay(0);
+ if (display)
+ {
+ ::Window focusWindow;
+ int revert;
+ // Get Focus window
+ XGetInputFocus(display, &focusWindow, &revert);
+
+ ecore_x_window_prop_property_set(focusWindow,
+ ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
+ ECORE_X_ATOM_CARDINAL, 32, &angle, 1);
+ XCloseDisplay(display);
+ }
+}
+
+} // namespace VirtualKeyboard
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "window-impl.h"
+
+// EXTERNAL HEADERS
+#include <Ecore.h>
+#include <Ecore_X.h>
+
+#include <dali/integration-api/core.h>
+#include <dali/integration-api/system-overlay.h>
+#include <dali/public-api/render-tasks/render-task.h>
+#include <dali/public-api/render-tasks/render-task-list.h>
+#include <orientation.h>
+
+// INTERNAL HEADERS
+#include <window-render-surface.h>
+#include <drag-and-drop-detector-impl.h>
+#include <indicator-impl.h>
+#include <window-visibility-observer.h>
+#include <orientation-impl.h>
+
+namespace
+{
+const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
+const float INDICATOR_SHOW_Y_POSITION( 0.0f );
+const float INDICATOR_HIDE_Y_POSITION( -52.0f );
+}
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_WINDOW");
+#endif
+
+/**
+ * TODO: Abstract Window class out and move this into a window implementation for Ecore
+ */
+struct Window::EventHandler
+{
+ /**
+ * Constructor
+ * @param[in] window A pointer to the window class.
+ */
+ EventHandler( Window* window )
+ : mWindow( window ),
+ mWindowPropertyHandler( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_PROPERTY, EcoreEventWindowPropertyChanged, this ) ),
+ mClientMessagehandler( ecore_event_handler_add( ECORE_X_EVENT_CLIENT_MESSAGE, EcoreEventClientMessage, this ) ),
+ mEcoreWindow( 0 )
+ {
+ // store ecore window handle
+ ECore::WindowRenderSurface* x11Window( dynamic_cast< ECore::WindowRenderSurface * >( mWindow->mSurface ) );
+ if( x11Window )
+ {
+ mEcoreWindow = x11Window->GetXWindow();
+ }
+ DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no ecore x window");
+
+ // set property on window to get deiconify approve client message
+ unsigned int tmp = 1;
+ ecore_x_window_prop_card32_set(mEcoreWindow,
+ ECORE_X_ATOM_E_DEICONIFY_APPROVE,
+ &tmp, 1);
+ }
+
+ /**
+ * Destructor
+ */
+ ~EventHandler()
+ {
+ if ( mWindowPropertyHandler )
+ {
+ ecore_event_handler_del( mWindowPropertyHandler );
+ }
+ if ( mClientMessagehandler )
+ {
+ ecore_event_handler_del( mClientMessagehandler );
+ }
+ }
+
+ // Static methods
+
+ /// Called when the window properties are changed.
+ static Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
+ {
+ Ecore_X_Event_Window_Property* propertyChangedEvent( (Ecore_X_Event_Window_Property*)event );
+ EventHandler* handler( (EventHandler*)data );
+ Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
+
+ if ( handler && handler->mWindow )
+ {
+ WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
+ if ( observer && ( propertyChangedEvent->win == handler->mEcoreWindow ) )
+ {
+ Ecore_X_Window_State_Hint state( ecore_x_icccm_state_get( propertyChangedEvent->win ) );
+
+ switch ( state )
+ {
+ case ECORE_X_WINDOW_STATE_HINT_WITHDRAWN:
+ {
+ // Window was hidden.
+ observer->OnWindowHidden();
+ DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Withdrawn\n", handler->mEcoreWindow );
+ handled = ECORE_CALLBACK_DONE;
+ }
+ break;
+
+ case ECORE_X_WINDOW_STATE_HINT_ICONIC:
+ {
+ // Window was iconified (minimised).
+ observer->OnWindowHidden();
+ DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Iconfied\n", handler->mEcoreWindow );
+ handled = ECORE_CALLBACK_DONE;
+ }
+ break;
+
+ case ECORE_X_WINDOW_STATE_HINT_NORMAL:
+ {
+ // Window was shown.
+ observer->OnWindowShown();
+ DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Shown\n", handler->mEcoreWindow );
+ handled = ECORE_CALLBACK_DONE;
+ }
+ break;
+
+ default:
+ // Ignore
+ break;
+ }
+ }
+ }
+
+ return handled;
+ }
+
+ /// Called when the window properties are changed.
+ static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
+ {
+ Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
+ Ecore_X_Event_Client_Message* clientMessageEvent( (Ecore_X_Event_Client_Message*)event );
+ EventHandler* handler( (EventHandler*)data );
+
+ if (clientMessageEvent->message_type == ECORE_X_ATOM_E_DEICONIFY_APPROVE)
+ {
+ ECore::WindowRenderSurface* x11Window( dynamic_cast< ECore::WindowRenderSurface * >( handler->mWindow->mSurface ) );
+ WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
+
+ if ( observer && ( (unsigned int)clientMessageEvent->data.l[0] == handler->mEcoreWindow ) )
+ {
+ if (clientMessageEvent->data.l[1] == 0) //wm sends request message using value 0
+ {
+ observer->OnWindowShown();
+
+ // request to approve the deiconify. render-surface should send proper event after real rendering
+ if(x11Window)
+ {
+ x11Window->RequestToApproveDeiconify();
+ }
+
+ handled = ECORE_CALLBACK_DONE;
+ }
+ }
+ }
+
+ return handled;
+ }
+
+ // Data
+ Window* mWindow;
+ Ecore_Event_Handler* mWindowPropertyHandler;
+ Ecore_Event_Handler* mClientMessagehandler;
+ Ecore_X_Window mEcoreWindow;
+};
+
+
+Window* Window::New(const PositionSize& posSize, const std::string& name, bool isTransparent)
+{
+ Window* window = new Window();
+ window->mIsTransparent = isTransparent;
+ window->Initialize(posSize, name);
+ return window;
+}
+
+void Window::SetAdaptor(Dali::Adaptor& adaptor)
+{
+ DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
+ mStarted = true;
+
+ // Only create one overlay per window
+ Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
+ Integration::Core& core = adaptorImpl.GetCore();
+ mOverlay = &core.GetSystemOverlay();
+
+ Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
+ taskList.CreateTask();
+
+ mAdaptor = &adaptorImpl;
+ mAdaptor->AddObserver( *this );
+
+ // Can only create the detector when we know the Core has been instantiated.
+ mDragAndDropDetector = DragAndDropDetector::New();
+ mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
+
+ if( mOrientation )
+ {
+ mOrientation->SetAdaptor(adaptor);
+ }
+
+ if( mIndicator != NULL )
+ {
+ mIndicator->SetAdaptor(mAdaptor);
+ }
+}
+
+RenderSurface* Window::GetSurface()
+{
+ return mSurface;
+}
+
+void Window::SetIndicatorStyle( Dali::Window::IndicatorStyle style )
+{
+ mIndicatorStyle = style;
+}
+
+void Window::ShowIndicator( bool show )
+{
+ DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "%s\n", show?"SHOW":"HIDE" );
+ DALI_ASSERT_DEBUG(mOverlay);
+
+ if(show)
+ {
+ mIndicatorVisible = Dali::Window::VISIBLE;
+ }
+ else
+ {
+ mIndicatorVisible = Dali::Window::INVISIBLE;
+ }
+
+ DoShowIndicator( mIndicatorOrientation );
+}
+
+void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
+{
+ DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
+ DALI_ASSERT_DEBUG(mOverlay);
+
+ ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
+ DALI_ASSERT_DEBUG(x11Window);
+ Ecore_X_Window xWinId = x11Window->GetXWindow();
+
+ mIndicatorVisible = visibleMode;
+
+ if ( mIndicatorVisible == Dali::Window::VISIBLE )
+ {
+ // when the indicator is visible, set proper mode for indicator server according to bg mode
+ if ( mIndicatorOpacityMode == Dali::Window::OPAQUE )
+ {
+ ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_OPAQUE);
+ }
+ else if ( mIndicatorOpacityMode == Dali::Window::TRANSLUCENT )
+ {
+ ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
+ }
+#if defined(DALI_PROFILE_MOBILE)
+ else if ( mIndicatorOpacityMode == Dali::Window::TRANSPARENT )
+ {
+ ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_BG_TRANSPARENT);
+ }
+#endif
+ }
+ else
+ {
+ // when the indicator is not visible, set TRANSPARENT mode for indicator server
+ ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_TRANSPARENT); // it means hidden indicator
+ }
+
+ DoShowIndicator( mIndicatorOrientation );
+}
+
+void Window::RotateIndicator(Dali::Window::WindowOrientation orientation)
+{
+ DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
+
+ DoRotateIndicator( orientation );
+}
+
+void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
+{
+ mIndicatorOpacityMode = opacityMode;
+
+ if( mIndicator != NULL )
+ {
+ mIndicator->SetOpacityMode( opacityMode );
+ }
+}
+
+void Window::SetClass(std::string name, std::string klass)
+{
+ // Get render surface's x11 window
+ if( mSurface )
+ {
+ ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ ecore_x_icccm_name_class_set( x11Window->GetXWindow(), name.c_str(), klass.c_str() );
+ }
+ }
+}
+
+Window::Window()
+: mSurface(NULL),
+ mIndicatorStyle(Dali::Window::CHANGEABLE_COLOR),
+ mIndicatorVisible(Dali::Window::VISIBLE),
+ mIndicatorIsShown(false),
+ mShowRotatedIndicatorOnClose(false),
+ mStarted(false),
+ mIsTransparent(false),
+ mWMRotationAppSet(false),
+ mIndicator(NULL),
+ mIndicatorOrientation(Dali::Window::PORTRAIT),
+ mNextIndicatorOrientation(Dali::Window::PORTRAIT),
+ mIndicatorOpacityMode(Dali::Window::OPAQUE),
+ mOverlay(NULL),
+ mAdaptor(NULL)
+{
+}
+
+Window::~Window()
+{
+ delete mEventHandler;
+
+ if ( mAdaptor )
+ {
+ mAdaptor->RemoveObserver( *this );
+ mAdaptor->SetDragAndDropDetector( NULL );
+ mAdaptor = NULL;
+ }
+
+ delete mSurface;
+}
+
+void Window::Initialize(const PositionSize& windowPosition, const std::string& name)
+{
+ // create an X11 window by default
+ Any surface;
+ Any display;
+ mSurface = new ECore::WindowRenderSurface( windowPosition, surface, display, name, mIsTransparent );
+ mOrientation = Orientation::New(this);
+
+ // create event handler for X11 window
+ mEventHandler = new EventHandler( this );
+}
+
+void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
+{
+ if( mIndicator == NULL )
+ {
+ if( mIndicatorVisible != Dali::Window::INVISIBLE )
+ {
+ mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, mIndicatorStyle, this );
+ mIndicator->SetOpacityMode( mIndicatorOpacityMode );
+ Dali::Actor actor = mIndicator->GetActor();
+ SetIndicatorActorRotation();
+ mOverlay->Add(actor);
+ }
+ // else don't create a hidden indicator
+ }
+ else // Already have indicator
+ {
+ if( mIndicatorVisible == Dali::Window::VISIBLE )
+ {
+ // If we are resuming, and rotation has changed,
+ if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
+ {
+ // then close current indicator and open new one
+ mShowRotatedIndicatorOnClose = true;
+ mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
+ // Don't show actor - will contain indicator for old orientation.
+ }
+ }
+ }
+
+ // set indicator visible mode
+ if( mIndicator != NULL )
+ {
+ mIndicator->SetVisible( mIndicatorVisible );
+ }
+
+ bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
+ SetIndicatorProperties( show, lastOrientation );
+ mIndicatorIsShown = show;
+}
+
+void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
+{
+ if( mIndicatorIsShown )
+ {
+ mShowRotatedIndicatorOnClose = true;
+ mNextIndicatorOrientation = orientation;
+ mIndicator->Close(); // May synchronously call IndicatorClosed() callback
+ }
+ else
+ {
+ // Save orientation for when the indicator is next shown
+ mShowRotatedIndicatorOnClose = false;
+ mNextIndicatorOrientation = orientation;
+ }
+}
+
+void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
+{
+ ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window win = x11Window->GetXWindow();
+
+ int show_state = static_cast<int>( isShow );
+ ecore_x_window_prop_property_set( win,
+ ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE,
+ ECORE_X_ATOM_CARDINAL, 32, &show_state, 1);
+
+ if ( isShow )
+ {
+ ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_ON);
+ }
+ else
+ {
+ ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
+ }
+ }
+}
+
+void Window::IndicatorTypeChanged(Indicator::Type type)
+{
+ ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window win = x11Window->GetXWindow();
+ switch(type)
+ {
+ case Indicator::INDICATOR_TYPE_1:
+ ecore_x_e_illume_indicator_type_set( win, ECORE_X_ILLUME_INDICATOR_TYPE_1 );
+ break;
+
+ case Indicator::INDICATOR_TYPE_2:
+ ecore_x_e_illume_indicator_type_set( win, ECORE_X_ILLUME_INDICATOR_TYPE_2 );
+ break;
+
+ case Indicator::INDICATOR_TYPE_UNKNOWN:
+ default:
+ break;
+ }
+ }
+}
+
+void Window::IndicatorClosed( Indicator* indicator )
+{
+ DALI_LOG_TRACE_METHOD( gWindowLogFilter );
+
+ if( mShowRotatedIndicatorOnClose )
+ {
+ Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
+ mIndicator->Open(mNextIndicatorOrientation);
+ mIndicatorOrientation = mNextIndicatorOrientation;
+ SetIndicatorActorRotation();
+ DoShowIndicator(currentOrientation);
+ }
+}
+
+void Window::SetIndicatorActorRotation()
+{
+ DALI_LOG_TRACE_METHOD( gWindowLogFilter );
+ DALI_ASSERT_DEBUG( mIndicator != NULL );
+
+ Dali::Actor actor = mIndicator->GetActor();
+ switch( mIndicatorOrientation )
+ {
+ case Dali::Window::PORTRAIT:
+ actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
+ actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ actor.SetRotation( Degree(0), Vector3::ZAXIS );
+ break;
+ case Dali::Window::PORTRAIT_INVERSE:
+ actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
+ actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ actor.SetRotation( Degree(180), Vector3::ZAXIS );
+ break;
+ case Dali::Window::LANDSCAPE:
+ actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
+ actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ actor.SetRotation( Degree(270), Vector3::ZAXIS );
+ break;
+ case Dali::Window::LANDSCAPE_INVERSE:
+ actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
+ actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ actor.SetRotation( Degree(90), Vector3::ZAXIS );
+ break;
+ }
+}
+
+void Window::Raise()
+{
+ ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window win = x11Window->GetXWindow();
+ ecore_x_window_raise(win);
+ }
+}
+
+void Window::Lower()
+{
+ ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window win = x11Window->GetXWindow();
+ ecore_x_window_lower(win);
+ }
+}
+
+void Window::Activate()
+{
+ ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window win = x11Window->GetXWindow();
+ ecore_x_netwm_client_active_request(ecore_x_window_root_get(win), win, 1 /* request type, 1:application, 2:pager */, 0);
+ }
+}
+
+Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
+{
+ return mDragAndDropDetector;
+}
+
+void Window::OnStart()
+{
+ DoShowIndicator( mIndicatorOrientation );
+}
+
+void Window::OnPause()
+{
+}
+
+void Window::OnResume()
+{
+ // resume indicator status
+ if( mIndicator != NULL )
+ {
+ // Restore own indicator opacity
+ // Send opacity mode to indicator service when app resumed
+ mIndicator->SetOpacityMode( mIndicatorOpacityMode );
+ }
+}
+
+void Window::OnStop()
+{
+ if( mIndicator )
+ {
+ mIndicator->Close();
+ }
+
+ delete mIndicator;
+ mIndicator = NULL;
+}
+
+void Window::OnDestroy()
+{
+ mAdaptor = NULL;
+}
+
+OrientationPtr Window::GetOrientation()
+{
+ return mOrientation;
+}
+
+void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
+{
+ bool found = false;
+
+ for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
+ {
+ if(mAvailableOrientations[i] == orientation)
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if( ! found )
+ {
+ mAvailableOrientations.push_back(orientation);
+ SetAvailableOrientations( mAvailableOrientations );
+ }
+}
+
+void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
+{
+ for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
+ iter != mAvailableOrientations.end(); ++iter )
+ {
+ if( *iter == orientation )
+ {
+ mAvailableOrientations.erase( iter );
+ break;
+ }
+ }
+ SetAvailableOrientations( mAvailableOrientations );
+}
+
+void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
+{
+ DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
+
+ mAvailableOrientations = orientations;
+ ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
+ if( ! mWMRotationAppSet )
+ {
+ mWMRotationAppSet = true;
+ ecore_x_e_window_rotation_app_set(ecoreWindow, EINA_TRUE);
+ }
+
+ int rotations[4];
+ for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
+ {
+ rotations[i] = static_cast<int>(mAvailableOrientations[i]);
+ }
+ ecore_x_e_window_rotation_available_rotations_set(ecoreWindow, rotations, mAvailableOrientations.size() );
+
+ }
+}
+
+const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
+{
+ return mAvailableOrientations;
+}
+
+void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
+{
+ mPreferredOrientation = orientation;
+
+ ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
+
+ if( ! mWMRotationAppSet )
+ {
+ mWMRotationAppSet = true;
+ ecore_x_e_window_rotation_app_set(ecoreWindow, EINA_TRUE);
+ }
+
+ ecore_x_e_window_rotation_preferred_rotation_set(ecoreWindow, orientation);
+ }
+}
+
+Dali::Window::WindowOrientation Window::GetPreferredOrientation()
+{
+ return mPreferredOrientation;
+}
+
+void Window::RotationDone( int orientation, int width, int height )
+{
+ // Tell window manager we're done
+ ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
+ if( x11Window )
+ {
+ Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
+ Ecore_X_Window root = ecore_x_window_root_get(ecoreWindow);
+
+ /**
+ * send rotation done message to wm, even if window is already rotated.
+ * that's why wm must be wait for comming rotation done message
+ * after sending rotation request.
+ */
+ ecore_x_e_window_rotation_change_done_send(root, ecoreWindow, orientation, width, height);
+
+ /**
+ * set rotate window property
+ */
+ int angles[2] = { orientation, orientation };
+ ecore_x_window_prop_property_set( ecoreWindow,
+ ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
+ ECORE_X_ATOM_CARDINAL, 32, &angles, 2 );
+ }
+}
+
+
+} // Adaptor
+} // Internal
+} // Dali
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "window-render-surface.h"
+
+// EXTERNAL INCLUDES
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <X11/extensions/Xfixes.h> // for damage notify
+#include <X11/extensions/Xdamage.h> // for damage notify
+
+#include <dali/integration-api/gl-abstraction.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <ecore-x-types.h>
+#include <trigger-event.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+#if defined(DEBUG_ENABLED)
+extern Debug::Filter* gRenderSurfaceLogFilter;
+#endif
+
+namespace ECore
+{
+
+namespace
+{
+
+const int MINIMUM_DIMENSION_CHANGE( 1 ); ///< Minimum change for window to be considered to have moved
+
+} // unnamed namespace
+
+WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent)
+: RenderSurface( Dali::RenderSurface::WINDOW, positionSize, surface, display, name, isTransparent ),
+ mNeedToApproveDeiconify(false)
+{
+ DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" );
+ Init( surface );
+}
+
+WindowRenderSurface::~WindowRenderSurface()
+{
+ if( mOwnSurface )
+ {
+ ecore_x_window_free( mX11Window );
+ }
+}
+
+Ecore_X_Drawable WindowRenderSurface::GetDrawable()
+{
+ // already an e-core type
+ return (Ecore_X_Drawable)mX11Window;
+}
+
+Dali::RenderSurface::SurfaceType WindowRenderSurface::GetType()
+{
+ return Dali::RenderSurface::WINDOW;
+}
+
+Any WindowRenderSurface::GetSurface()
+{
+ // already an e-core type
+ return Any( mX11Window );
+}
+
+Ecore_X_Window WindowRenderSurface::GetXWindow()
+{
+ return mX11Window;
+}
+
+void WindowRenderSurface::RequestToApproveDeiconify()
+{
+ mNeedToApproveDeiconify = true;
+}
+
+void WindowRenderSurface::InitializeEgl( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+ eglImpl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
+
+ eglImpl.ChooseConfig(true, mColorDepth);
+}
+
+void WindowRenderSurface::CreateEglSurface( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+
+ // create the EGL surface
+ // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
+ XWindow window = static_cast< XWindow>( mX11Window );
+ eglImpl.CreateSurfaceWindow( (EGLNativeWindowType)window, mColorDepth ); // reinterpret_cast does not compile
+}
+
+void WindowRenderSurface::DestroyEglSurface( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( eglIf );
+ eglImpl.DestroySurface();
+}
+
+bool WindowRenderSurface::ReplaceEGLSurface( EglInterface& eglIf )
+{
+ DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+
+ EglImplementation& egl = static_cast<EglImplementation&>( eglIf );
+ egl.InitializeGles( reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
+
+ // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
+ XWindow window = static_cast< XWindow >( mX11Window );
+ return egl.ReplaceSurfaceWindow( (EGLNativeWindowType)window, // reinterpret_cast does not compile
+ reinterpret_cast< EGLNativeDisplayType >( mMainDisplay ) );
+}
+
+void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize )
+{
+ bool needToMove = false;
+ bool needToResize = false;
+
+ // check moving
+ if( (fabs(positionSize.x - mPosition.x) > MINIMUM_DIMENSION_CHANGE) ||
+ (fabs(positionSize.y - mPosition.y) > MINIMUM_DIMENSION_CHANGE) )
+ {
+ needToMove = true;
+ }
+
+ // check resizing
+ if( (fabs(positionSize.width - mPosition.width) > MINIMUM_DIMENSION_CHANGE) ||
+ (fabs(positionSize.height - mPosition.height) > MINIMUM_DIMENSION_CHANGE) )
+ {
+ needToResize = true;
+ }
+
+ if( needToMove && needToResize)
+ {
+ ecore_x_window_move_resize(mX11Window, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
+ mPosition = positionSize;
+ }
+ else if(needToMove)
+ {
+ ecore_x_window_move(mX11Window, positionSize.x, positionSize.y);
+ mPosition = positionSize;
+ }
+ else if (needToResize)
+ {
+ ecore_x_window_resize(mX11Window, positionSize.width, positionSize.height);
+ mPosition = positionSize;
+ }
+
+}
+
+void WindowRenderSurface::Map()
+{
+ ecore_x_window_show(mX11Window);
+}
+
+bool WindowRenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& )
+{
+ // nothing to do for windows
+ return true;
+}
+
+void WindowRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int, SyncMode )
+{
+ EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );
+ eglImpl.SwapBuffers();
+
+ // When the window is deiconified, it approves the deiconify operation to window manager after rendering
+ if(mNeedToApproveDeiconify)
+ {
+ // SwapBuffer is desychronized. So make sure to sychronize when window is deiconified.
+ glAbstraction.Finish();
+
+ /* client sends immediately reply message using value 1 */
+ ecore_x_client_message32_send(mX11Window,
+ ECORE_X_ATOM_E_DEICONIFY_APPROVE,
+ ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
+ mX11Window, 1,
+ 0, 0, 0);
+
+ ecore_x_sync();
+
+ mNeedToApproveDeiconify = false;
+ }
+}
+
+void WindowRenderSurface::SetViewMode( ViewMode viewMode )
+{
+ Ecore_X_Atom viewModeAtom( ecore_x_atom_get( "_E_COMP_3D_APP_WIN" ) );
+
+ if( viewModeAtom != None )
+ {
+ unsigned int value( static_cast<unsigned int>( viewMode ) );
+ ecore_x_window_prop_card32_set( mX11Window, viewModeAtom, &value, 1 );
+ }
+}
+
+void WindowRenderSurface::CreateXRenderable()
+{
+ // if width or height are zero, go full screen.
+ if ( (mPosition.width == 0) || (mPosition.height == 0) )
+ {
+ // Default window size == screen size
+ mPosition.x = 0;
+ mPosition.y = 0;
+
+ ecore_x_screen_size_get( ecore_x_default_screen_get(), &mPosition.width, &mPosition.height );
+ }
+
+ if(mColorDepth == COLOR_DEPTH_32)
+ {
+ // create 32 bit window
+ mX11Window = ecore_x_window_argb_new( 0, mPosition.x, mPosition.y, mPosition.width, mPosition.height );
+ }
+ else
+ {
+ // create 24 bit window
+ mX11Window = ecore_x_window_new( 0, mPosition.x, mPosition.y, mPosition.width, mPosition.height );
+ }
+
+ if ( mX11Window == 0 )
+ {
+ DALI_ASSERT_ALWAYS(0 && "Failed to create X window");
+ }
+
+ // set up window title which will be helpful for debug utitilty
+ ecore_x_icccm_title_set( mX11Window, mTitle.c_str() );
+ ecore_x_netwm_name_set( mX11Window, mTitle.c_str() );
+
+ // set up etc properties to match with ecore-evas
+ char *id = NULL;
+ if( ( id = getenv("DESKTOP_STARTUP_ID") ) )
+ {
+ ecore_x_netwm_startup_id_set( mX11Window, id );
+ }
+
+ ecore_x_icccm_hints_set( mX11Window,
+ 1, // accepts_focus
+ ECORE_X_WINDOW_STATE_HINT_NORMAL, // initial_state
+ 0, // icon_pixmap
+ 0, // icon_mask
+ 0, // icon_window
+ 0, // window_group
+ 0 ); // is_urgent
+
+ // we SHOULD guarantee the x11 window was created in x server.
+ ecore_x_sync();
+}
+
+void WindowRenderSurface::UseExistingRenderable( unsigned int surfaceId )
+{
+ mX11Window = static_cast< Ecore_X_Window >( surfaceId );
+}
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ECORE_X_WINDOW_RENDER_SURFACE_H__
+#define __DALI_INTERNAL_ECORE_X_WINDOW_RENDER_SURFACE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <ecore-x-render-surface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace ECore
+{
+
+/**
+ * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface.
+ * Window specialization.
+ */
+class WindowRenderSurface : public RenderSurface
+{
+public:
+
+ /**
+ * Uses an X11 surface to render to.
+ * @param [in] positionSize the position and size of the surface
+ * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
+ * @param [in] display connection to X-server if the surface is a X window or pixmap (type must be void * to X display struct)
+ * @param [in] name optional name of surface passed in
+ * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
+ */
+ WindowRenderSurface( Dali::PositionSize positionSize,
+ Any surface,
+ Any display,
+ const std::string& name,
+ bool isTransparent = false );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface::~RenderSurface
+ */
+ virtual ~WindowRenderSurface();
+
+public: // API
+
+ /**
+ * @copydoc Dali::RenderSurface::GetDrawable()
+ */
+ virtual Ecore_X_Drawable GetDrawable();
+
+ /**
+ * Request to approve deiconify operation
+ * If it is requested, it will send ECORE_X_ATOM_E_DEICONIFY_APPROVE event to window manager after rendering
+ */
+ void RequestToApproveDeiconify();
+
+public: // from Dali::RenderSurface
+
+ /**
+ * @copydoc Dali::RenderSurface::GetType()
+ */
+ virtual Dali::RenderSurface::SurfaceType GetType();
+
+ /**
+ * @copydoc Dali::RenderSurface::GetSurface()
+ */
+ virtual Any GetSurface();
+
+ /**
+ * @copydoc Dali::RenderSurface::GetDrawable()
+ */
+ virtual Ecore_X_Window GetXWindow();
+
+public: // from Internal::Adaptor::RenderSurface
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::InitializeEgl()
+ */
+ virtual void InitializeEgl( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface()
+ */
+ virtual void CreateEglSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface()
+ */
+ virtual void DestroyEglSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface()
+ */
+ virtual bool ReplaceEGLSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::MoveResize()
+ */
+ virtual void MoveResize( Dali::PositionSize positionSize);
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::Map()
+ */
+ virtual void Map();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::PreRender()
+ */
+ virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::PostRender()
+ */
+ virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode );
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::RenderSurface::SetViewMode()
+ */
+ void SetViewMode( ViewMode viewMode );
+
+protected:
+
+ /**
+ * Create XWindow
+ */
+ virtual void CreateXRenderable();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface::UseExistingRenderable
+ */
+ virtual void UseExistingRenderable( unsigned int surfaceId );
+
+private: // Data
+
+ Ecore_X_Window mX11Window; ///< X-Window
+ bool mNeedToApproveDeiconify; ///< Whether need to send ECORE_X_ATOM_E_DEICONIFY_APPROVE event
+
+}; // class WindowRenderSurface
+
+} // namespace ECore
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ECORE_X_WINDOW_RENDER_SURFACE_H__
include ../../../platform-abstractions/slp/file.list
# Internal Common
-tizen_adaptor_internal_src_dir = ../../../adaptors/tizen/internal/common
-include ../../../adaptors/tizen/internal/common/file.list
+adaptor_common_dir = ../../../adaptors/common
+include ../../../adaptors/common/file.list
+
+if WAYLAND
+adaptor_wayland_dir = ../../../adaptors/wayland
+include ../../../adaptors/wayland/file.list
+else
+adaptor_x11_dir = ../../../adaptors/x11
+include ../../../adaptors/x11/file.list
+endif
if COMMON_PROFILE
-tizen_adaptor_internal_common_src_files += $(tizen_adaptor_internal_common_profile_src_files)
+adaptor_common_internal_src_files += $(adaptor_common_internal_profile_src_files)
slp_platform_abstraction_src_files += $(slp_assimp_stubs_src_files)
+if ! WAYLAND
+adaptor_common_internal_src_files += $(adaptor_x11_common_internal_profile_src_files)
+endif
+endif
+
+if WAYLAND
+adaptor_common_internal_src_files += $(adaptor_wayland_internal_src_files)
+adaptor_common_internal_profile_src_files += $(adaptor_wayland_profile_src_files)
+else
+adaptor_common_internal_src_files += $(adaptor_x11_internal_src_files)
+adaptor_common_internal_profile_src_files += $(adaptor_x11_profile_src_files)
endif
if MOBILE_PROFILE
+adaptor_common_internal_src_files += $(adaptor_x11_profile_src_files)
slp_platform_abstraction_src_files += $(slp_assimp_src_files)
-include ../../../adaptors/tizen/internal/mobile/file.list
+include ../../../adaptors/mobile/file.list
endif
if LITE_PROFILE
-tizen_adaptor_internal_common_src_files += $(tizen_adaptor_internal_common_profile_src_files)
+adaptor_common_internal_src_files += $(adaptor_common_internal_profile_src_files)
slp_platform_abstraction_src_files += $(slp_assimp_stubs_src_files)
+if ! WAYLAND
+adaptor_common_internal_src_files += $(adaptor_x11_common_internal_profile_src_files)
+endif
endif
if WEARABLE_PROFILE
-tizen_adaptor_internal_common_src_files += $(tizen_adaptor_internal_common_profile_src_files)
+adaptor_common_internal_src_files += $(adaptor_common_internal_profile_src_files)
slp_platform_abstraction_src_files += $(slp_assimp_stubs_src_files)
+if ! WAYLAND
+adaptor_common_internal_src_files += $(adaptor_x11_common_internal_profile_src_files)
+endif
endif
if TV_PROFILE
slp_platform_abstraction_src_files += $(slp_assimp_src_files)
-include ../../../adaptors/tizen/internal/tv/file.list
+include ../../../adaptors/tv/file.list
endif
# Public API
-tizen_adaptor_public_api_src_dir = ../../../adaptors/tizen/public-api
-include ../../../adaptors/tizen/public-api/file.list
-
-# CAPI API
-capi_src_dir = ../../../capi/dali/public-api
-include ../../../capi/dali/public-api/file.list
+adaptor_public_api_dir = ../../../adaptors/public-api
+include ../../../adaptors/public-api/file.list
# Feedback Plugin
if ! LITE_PROFILE
-plugin_themes_dir = ../../../adaptors/tizen/internal/common/feedback
+plugin_themes_dir = ../../../adaptors/common/feedback
dali_plugin_theme_files = $(plugin_themes_dir)/default-feedback-theme.json
dalifeedbackthemedir = ${dataReadOnlyDir}/themes/feedback-themes/
libdali_adaptor_common_la_SOURCES = \
$(base_adaptor_src_files) \
$(slp_platform_abstraction_src_files) \
- $(tizen_adaptor_public_api_src_files) \
- $(tizen_adaptor_internal_common_src_files)
+ $(adaptor_common_src_files) \
+ $(adaptor_common_internal_src_files)
libdali_adaptor_common_la_DEPENDENCIES =
-I../../../platform-abstractions/slp/resource-loader \
-I../../../platform-abstractions/portable \
-I../../../platform-abstractions/ \
- -I../../../adaptors/tizen \
- -I../../../adaptors/ \
- -I../../../capi/
+ -I../../../adaptors/public-api \
+ -I../../../adaptors/common \
+ -I../../../adaptors/
+if WAYLAND
+libdali_adaptor_common_la_includes += \
+ -I../../../adaptors/wayland
+else
+libdali_adaptor_common_la_includes += \
+ -I../../../adaptors/x11
+endif
daliDefaultFontCacheDir = ${dataReadOnlyDir}/glyphcache/
daliUserFontCacheDir = ${dataReadWriteDir}/glyphcache/
$(DALI_ADAPTOR_CFLAGS) \
$(DALICORE_CFLAGS) \
$(OPENGLES20_CFLAGS) \
- $(X11_CFLAGS) \
$(FREETYPE_CFLAGS) \
$(FONTCONFIG_CFLAGS) \
$(PNG_CFLAGS) \
libdali_adaptor_common_la_LIBADD = \
$(DALICORE_LIBS) \
- $(X11_LIBS) \
$(OPENGLES20_LIBS) \
$(FREETYPE_LIBS) \
$(FONTCONFIG_LIBS) \
$(PNG_LIBS) \
$(ELEMENTARY_LIBS) \
- $(ECORE_X_LIBS) \
$(ECORE_IPC_LIBS) \
$(DLOG_LIBS) \
$(XML_LIBS) \
-lgif \
-lboost_thread
+if WAYLAND
+libdali_adaptor_common_la_CXXFLAGS += $(WAYLAND_CFLAGS)
+libdali_adaptor_common_la_LIBADD += $(WAYLAND_LIBS)
+else
+libdali_adaptor_common_la_CXXFLAGS += $(X11_CFLAGS)
+libdali_adaptor_common_la_LIBADD += $(X11_LIBS)
+libdali_adaptor_common_la_LIBADD += $(ECORE_X_LIBS)
+endif
+
if COMMON_PROFILE
libdali_adaptor_common_la_CXXFLAGS += $(HAPTIC_CFLAGS)
endif
libdali_adaptor_common_la_LIBADD += -ljpeg
endif
-tizenadaptorcommonpublicapidir = $(devincludepath)/dali/public-api/adaptor-framework/common
-tizenadaptorcommonpublicapi_HEADERS = $(tizen_adaptor_public_api_common_header_files)
+tizenadaptorcommonpublicapidir = $(devincludepath)/dali/public-api/
+tizenadaptorcommonpublicapi_HEADERS = $(public_api_header_files)
tizenadaptordaliheaderdir = $(devincludepath)/dali
-tizenadaptordaliheader_HEADERS = $(tizen_adaptor_dali_header_file)
+tizenadaptordaliheader_HEADERS = $(adaptor_dali_header_file)
-capicommonpublicapidir = $(devincludepath)/dali/public-api/adaptor-framework/common
-capicommonpublicapi_HEADERS = $(capi_adaptor_framework_common_header_files)
+capicommonpublicapidir = $(devincludepath)/dali/public-api/
+capicommonpublicapi_HEADERS = $(public_api_header_files)
capiheaderdir = $(devincludepath)/dali/public-api/
-capiheader_HEADERS = $(capi_header_file)
+capiheader_HEADERS = $(adaptor_dali_header_file)
PKG_CHECK_MODULES(DLOG, dlog)
PKG_CHECK_MODULES(ELEMENTARY, elementary)
PKG_CHECK_MODULES(ECORE, ecore)
-PKG_CHECK_MODULES(ECORE_X, ecore-x)
PKG_CHECK_MODULES(ECORE_IPC, ecore-ipc)
PKG_CHECK_MODULES(EXIF, libexif)
PKG_CHECK_MODULES(FREETYPE, [freetype2 >= $FREETYPE_REQUIRED])
PKG_CHECK_MODULES(SENSOR, sensor)
PKG_CHECK_MODULES(TTS, tts)
PKG_CHECK_MODULES(VCONF, vconf)
-PKG_CHECK_MODULES(X11, x11)
PKG_CHECK_MODULES(XML, libxml-2.0)
PKG_CHECK_MODULES(LIBDRM, libdrm)
PKG_CHECK_MODULES(LIBEXIF, libexif)
AC_ARG_ENABLE([profile],
[AC_HELP_STRING([--enable-profile=COMMON,MOBILE,LITE,WEARABLE,TV],
[Select the variant of tizen])],
- [dali_profile=$enableval],
- [dali_profile=COMMON])
-
-if test "x$enable_profile" = "xyes"; then
- dali_profile=COMMON
-fi
-if test "x$enable_profile" = "x"; then
- dali_profile=COMMON
-fi
-
-DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DDALI_PROFILE_${dali_profile}"
-DALI_PROFILE_CFLAGS=" -DDALI_PROFILE_${dali_profile}"
-AM_CONDITIONAL([COMMON_PROFILE], [test x$dali_profile = xCOMMON])
-AM_CONDITIONAL([MOBILE_PROFILE], [test x$dali_profile = xMOBILE])
-AM_CONDITIONAL([LITE_PROFILE], [test x$dali_profile = xLITE])
-AM_CONDITIONAL([WEARABLE_PROFILE], [test x$dali_profile = xWEARABLE])
-AM_CONDITIONAL([TV_PROFILE], [test x$dali_profile = xTV])
+ [enable_profile=$enableval],
+ [enable_profile=COMMON])
+
+AC_ARG_ENABLE(wayland,
+ [ --enable-wayland Build on Wayland],
+ enable_wayland=yes,
+ enable_wayland=no)
+
+DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DDALI_PROFILE_${enable_profile}"
+DALI_PROFILE_CFLAGS=" -DDALI_PROFILE_${enable_profile}"
+AM_CONDITIONAL([COMMON_PROFILE], [test x$enable_profile = xCOMMON])
+AM_CONDITIONAL([MOBILE_PROFILE], [test x$enable_profile = xMOBILE])
+AM_CONDITIONAL([LITE_PROFILE], [test x$enable_profile = xLITE])
+AM_CONDITIONAL([WEARABLE_PROFILE], [test x$enable_profile = xWEARABLE])
+AM_CONDITIONAL([TV_PROFILE], [test x$enable_profile = xTV])
+AM_CONDITIONAL([WAYLAND], [test x$enable_wayland = xyes])
if test "x$enable_profile" = "xCOMMON"; then
+if test "x$enable_wayland" = "xyes"; then
+PKG_CHECK_MODULES(OPENGLES20, glesv2)
+else
PKG_CHECK_MODULES(OPENGLES20, gles20)
+fi
PKG_CHECK_MODULES(HAPTIC, haptic)
fi
PKG_CHECK_MODULES(HAPTIC, haptic)
fi
+if test "x$enable_wayland" = "xyes"; then
+PKG_CHECK_MODULES(WAYLAND, [ecore-wayland egl wayland-egl wayland-client >= 1.2.0 xkbcommon],
+ [DALI_HAS_ECOREWL=yes],
+ [DALI_HAS_ECOREWL=no])
+else
+PKG_CHECK_MODULES(ECORE_X, [ecore-x],
+ [DALI_HAS_ECOREX=yes],
+ [DALI_HAS_ECOREX=no])
+PKG_CHECK_MODULES(X11, [x11],
+ [DALI_HAS_X11=yes],
+ [DALI_HAS_X11=no])
+fi
+
if test x$DALI_DATA_RW_DIR != x; then
dataReadWriteDir=$DALI_DATA_RW_DIR
else
Debug Build: $enable_debug
Compile flags $DALI_ADAPTOR_CFLAGS
Using JPEG Turbo Library: $with_jpeg_turbo
- Profile: $dali_profile
+ Profile: $enable_profile
Data Dir (Read/Write): $dataReadWriteDir
Data Dir (Read Only): $dataReadOnlyDir
Font Path (Preloaded): $fontPreloadedPath
# Builds the Dali Adaptor + all applications library
-tizen_application_internal_src_dir = ../../../adaptors/tizen/internal
-include ../../../adaptors/tizen/internal/application-file.list
-
-tizen_application_public_api_src_dir = ../../../adaptors/tizen/public-api
-include ../../../adaptors/tizen/public-api/adaptor-framework/application-file.list
+# Common
+adaptor_common_dir = ../../../adaptors/common
+include ../../../adaptors/common/file.list
+
+# Public API
+adaptor_public_api_dir = ../../../adaptors/public-api
+include ../../../adaptors/public-api/file.list
+
+if WAYLAND
+adaptor_wayland_dir = ../../../adaptors/wayland
+include ../../../adaptors/wayland/file.list
+else
+adaptor_x11_dir = ../../../adaptors/x11
+include ../../../adaptors/x11/file.list
+endif
if MOBILE_PROFILE
-tizen_evas_plugin_internal_src_dir = ../../../adaptors/tizen/internal/mobile
-tizen_native_buffer_plugin_internal_src_dir = ../../../adaptors/tizen/internal/mobile
-include ../../../adaptors/tizen/internal/mobile/application-file.list
-
-tizen_evas_plugin_public_api_src_dir = ../../../adaptors/tizen/public-api
-tizen_native_buffer_plugin_public_api_src_dir = ../../../adaptors/tizen/public-api
-include ../../../adaptors/tizen/public-api/adaptor-framework/mobile/application-file.list
+tizen_evas_plugin_internal_src_dir = ../../../adaptors/mobile
+tizen_native_buffer_plugin_internal_src_dir = ../../../adaptors/mobile
+tizen_evas_plugin_public_api_src_dir = ../../../adaptors/mobile
+tizen_native_buffer_plugin_public_api_src_dir = ../../../adaptors/mobile
+include ../../../adaptors/mobile/application-file.list
endif
-capi_public_api_src_dir = ../../../capi/dali/public-api
-include ../../../capi/dali/public-api/file.list
-
lib_LTLIBRARIES = libdali-adaptor.la
-libdali_adaptor_la_SOURCES = $(tizen_application_public_api_src_files)
+libdali_adaptor_la_SOURCES = $(adaptor_application_src_files)
if MOBILE_PROFILE
libdali_adaptor_la_SOURCES += $(tizen_evas_plugin_public_api_src_files) \
$(tizen_native_buffer_plugin_public_api_src_files)
endif
-libdali_adaptor_la_SOURCES += $(tizen_application_internal_src_files)
+libdali_adaptor_la_SOURCES += $(adaptor_application_internal_src_files)
+
+if WAYLAND
+libdali_adaptor_la_SOURCES += $(adaptor_wayland_application_src_files)
+else
+libdali_adaptor_la_SOURCES += $(adaptor_x11_application_src_files)
+endif
if MOBILE_PROFILE
libdali_adaptor_la_SOURCES += $(tizen_evas_plugin_internal_src_files) \
-I../../../platform-abstractions/slp \
-I../../../platform-abstractions/slp/resource-loader \
-I../../../platform-abstractions/portable \
- -I../../../adaptors/ \
- -I../../../adaptors/tizen \
- -I../../../capi
+ -I../../../adaptors/public-api \
+ -I../../../adaptors/common \
+ -I../../../adaptors/
+
+if WAYLAND
+libdali_adaptor_includes += \
+ -I../../../adaptors/wayland
+else
+libdali_adaptor_includes += \
+ -I../../../adaptors/x11
+endif
daliUserFontCacheDir = ${dataReadWriteDir}/glyphcache/
daliDefaultThemeDir = ${dataReadWriteDir}/theme/
$(PNG_CFLAGS) \
$(CAPI_APPFW_APPLICATION_CFLAGS) \
$(ELEMENTARY_CFLAGS) \
+ $(ECORE_IPC_CFLAGS) \
$(DLOG_CFLAGS) \
$(XML_CFLAGS) \
$(VCONF_CFLAGS) \
$(MKDIR_P) ${DESTDIR}/${daliUserFontCacheDir}
# Install resource log analyzer script
-bin_SCRIPTS = ../../../adaptors/tizen/scripts/dalireslog.sh
+bin_SCRIPTS = ../../../adaptors/scripts/dalireslog.sh
# Install headers
-tizenadaptorpublicapidir = $(devincludepath)/dali/public-api/adaptor-framework
-tizenadaptorpublicapi_HEADERS = $(tizen_application_public_api_header_files)
+tizenadaptorpublicapidir = $(devincludepath)/dali/public-api/
+tizenadaptorpublicapi_HEADERS = $(public_api_application_header_files)
# linking test
linker_test_SOURCES = linker-test.cpp
linker_test_CXXFLAGS = \
- -I../../../adaptors/tizen \
- -I../../../capi \
+ -I../../../adaptors/common \
+ -I../../../adaptors/public-api \
$(DALI_ADAPTOR_CFLAGS) \
$(DALICORE_CFLAGS) \
$(DALIX11_CFLAGS) \
#include <dali/public-api/dali-core.h>
-#include "public-api/adaptor-framework/application.h"
+#include "application.h"
-#include <dali/public-api/adaptor-framework/common/adaptor.h>
-#include <dali/public-api/adaptor-framework/common/render-surface.h>
-#include <dali/public-api/adaptor-framework/common/orientation.h>
-#include <dali/public-api/adaptor-framework/common/timer.h>
+#include <adaptor.h>
+#include <render-surface.h>
+#include <orientation.h>
+#include <timer.h>
using namespace Dali;
# Build the Dali Adaptor + Application library
-tizen_application_internal_src_dir = ../../../adaptors/tizen/internal
-include ../../../adaptors/tizen/internal/application-file.list
-
-tizen_application_public_api_src_dir = ../../../adaptors/tizen/public-api
-include ../../../adaptors/tizen/public-api/adaptor-framework/application-file.list
-
-capi_public_api_src_dir = ../../../capi/dali/public-api
-include ../../../capi/dali/public-api/file.list
+# Common
+adaptor_common_dir = ../../../adaptors/common
+include ../../../adaptors/common/file.list
+
+# Public API
+adaptor_public_api_dir = ../../../adaptors/public-api
+include ../../../adaptors/public-api/file.list
+
+if WAYLAND
+adaptor_wayland_dir = ../../../adaptors/wayland
+include ../../../adaptors/wayland/file.list
+else
+adaptor_x11_dir = ../../../adaptors/x11
+include ../../../adaptors/x11/file.list
+endif
lib_LTLIBRARIES = libdali-application.la
libdali_application_la_SOURCES = \
- $(tizen_application_public_api_src_files) \
- $(tizen_application_internal_src_files)
+ $(adaptor_application_src_files) \
+ $(adaptor_application_internal_src_files)
+
+if WAYLAND
+libdali_application_la_SOURCES += $(adaptor_wayland_application_src_files)
+else
+libdali_application_la_SOURCES += $(adaptor_x11_application_src_files)
+endif
libdali_application_la_DEPENDENCIES =
-I../../../platform-abstractions/slp \
-I../../../platform-abstractions/slp/resource-loader \
-I../../../platform-abstractions/portable \
- -I../../../adaptors/ \
- -I../../../adaptors/tizen \
- -I../../../capi
+ -I../../../adaptors/public-api \
+ -I../../../adaptors/common \
+ -I../../../adaptors/
+
+if WAYLAND
+libdali_application_includes += \
+ -I../../../adaptors/wayland
+else
+libdali_application_includes += \
+ -I../../../adaptors/x11
+endif
daliUserFontCacheDir = ${dataReadWriteDir}/glyphcache/
daliDefaultThemeDir = ${dataReadWriteDir}/theme/
$(ASSIMP_CFLAGS) \
$(CAPI_APPFW_APPLICATION_CFLAGS) \
$(ELEMENTARY_CFLAGS) \
+ $(ECORE_IPC_CFLAGS) \
$(DLOG_CFLAGS) \
$(XML_CFLAGS) \
$(VCONF_CFLAGS) \
$(MKDIR_P) ${DESTDIR}/${daliUserFontCacheDir} ${DESTDIR}/${daliUserShaderCacheDir}
# Install resource log analyzer script
-bin_SCRIPTS = ../../../adaptors/tizen/scripts/dalireslog.sh
+bin_SCRIPTS = ../../../adaptors/scripts/dalireslog.sh
# Install headers
-tizenadaptorpublicapidir = $(devincludepath)/dali/public-api/adaptor-framework
-tizenadaptorpublicapi_HEADERS = $(tizen_application_public_api_header_files)
+tizenadaptorpublicapidir = $(devincludepath)/dali/public-api/
+tizenadaptorpublicapi_HEADERS = $(public_api_application_header_files)
# linking test
linker_test_SOURCES = linker-test.cpp
linker_test_CXXFLAGS = \
- -I../../../adaptors/tizen \
- -I../../../capi \
+ -I../../../adaptors/common \
+ -I../../../adaptors/public-api \
$(DALI_ADAPTOR_CFLAGS) \
$(DALICORE_CFLAGS) \
$(DALIX11_CFLAGS) \
#include <dali/public-api/dali-core.h>
-#include <public-api/adaptor-framework/application.h>
-#include <dali/public-api/adaptor-framework/common/adaptor.h>
-#include <dali/public-api/adaptor-framework/common/render-surface.h>
-#include <dali/public-api/adaptor-framework/common/orientation.h>
-#include <dali/public-api/adaptor-framework/common/timer.h>
+#include <application.h>
+#include <adaptor.h>
+#include <render-surface.h>
+#include <orientation.h>
+#include <timer.h>
using namespace Dali;
# Build the Dali Adaptor + Evas Plugin library
-tizen_evas_plugin_internal_src_dir = ../../../adaptors/tizen/internal/mobile
-include ../../../adaptors/tizen/internal/mobile/application-file.list
+tizen_evas_plugin_internal_src_dir = ../../../adaptors/mobile
+tizen_evas_plugin_public_api_src_dir = ../../../adaptors/mobile
+include ../../../adaptors/mobile/application-file.list
-tizen_evas_plugin_public_api_src_dir = ../../../adaptors/tizen/public-api
-include ../../../adaptors/tizen/public-api/adaptor-framework/mobile/application-file.list
-
-capi_public_api_src_dir = ../../../capi/dali/public-api
-include ../../../capi/dali/public-api/file.list
+# Public API
+adaptor_public_api_dir = ../../../adaptors/public-api
+include ../../../adaptors/public-api/file.list
lib_LTLIBRARIES = libdali-evas-plugin.la
-I../../../platform-abstractions/slp \
-I../../../platform-abstractions/slp/resource-loader \
-I../../../platform-abstractions/portable \
- -I../../../adaptors/ \
- -I../../../adaptors/tizen \
- -I../../../capi/
+ -I../../../adaptors/public-api \
+ -I../../../adaptors/common \
+ -I../../../adaptors/
+
+if WAYLAND
+libdali_evas_plugin_includes += \
+ -I../../../adaptors/wayland
+else
+libdali_evas_plugin_includes += \
+ -I../../../adaptors/x11
+endif
daliDefaultFontCacheDir = ${dataReadOnlyDir}/glyphcache/
daliUserFontCacheDir = ${dataReadWriteDir}/glyphcache/
$(ELEMENTARY_LIBS) \
$(EVAS_LIBS)
-tizenadaptordaliheaderdir = $(devincludepath)/dali/public-api/adaptor-framework
+tizenadaptordaliheaderdir = $(devincludepath)/dali/public-api/
tizenadaptordaliheader_HEADERS = $(tizen_evas_plugin_public_api_header_files) \
- $(capi_evas_plugin_public_api_header_files)
+ $(evas_plugin_public_api_header_files)
# linking test
linker_test_SOURCES = linker-test.cpp
linker_test_CXXFLAGS = \
- -I../../../adaptors/tizen \
- -I../../../capi \
+ -I../../../adaptors/common \
+ -I../../../adaptors/public-api \
$(DALI_ADAPTOR_CFLAGS) \
$(DALICORE_CFLAGS) \
$(DALIX11_CFLAGS) \
#include <dali/public-api/dali-core.h>
-#include <dali/public-api/adaptor-framework/evas-plugin.h>
-#include <dali/public-api/adaptor-framework/common/adaptor.h>
-#include <dali/public-api/adaptor-framework/common/render-surface.h>
-#include <dali/public-api/adaptor-framework/common/orientation.h>
-#include <dali/public-api/adaptor-framework/common/timer.h>
+#include <evas-plugin.h>
+#include <adaptor.h>
+#include <render-surface.h>
+#include <orientation.h>
+#include <timer.h>
using namespace Dali;
# Build the Dali Adaptor + Native Buffer Plugin library
-tizen_native_buffer_plugin_internal_src_dir = ../../../adaptors/tizen/internal/mobile
-include ../../../adaptors/tizen/internal/mobile/application-file.list
+tizen_native_buffer_plugin_internal_src_dir = ../../../adaptors/mobile
+tizen_native_buffer_plugin_public_api_src_dir = ../../../adaptors/mobile
+include ../../../adaptors/mobile/application-file.list
-tizen_native_buffer_plugin_public_api_src_dir = ../../../adaptors/tizen/public-api
-include ../../../adaptors/tizen/public-api/adaptor-framework/mobile/application-file.list
-
-capi_public_api_src_dir = ../../../capi/dali/public-api
-include ../../../capi/dali/public-api/file.list
+# Public API
+adaptor_public_api_dir = ../../../adaptors/public-api
+include ../../../adaptors/public-api/file.list
lib_LTLIBRARIES = libdali-native-buffer-plugin.la
-I../../../platform-abstractions/slp \
-I../../../platform-abstractions/slp/resource-loader \
-I../../../platform-abstractions/portable \
- -I../../../adaptors/ \
- -I../../../adaptors/tizen \
- -I../../../capi
+ -I../../../adaptors/public-api \
+ -I../../../adaptors/common \
+ -I../../../adaptors/
+
+if WAYLAND
+libdali_native_buffer_plugin_includes += \
+ -I../../../adaptors/wayland
+else
+libdali_native_buffer_plugin_includes += \
+ -I../../../adaptors/x11
+endif
daliDefaultFontCacheDir = ${dataReadOnlyDir}/glyphcache/
daliUserFontCacheDir = ${dataReadWriteDir}/glyphcache/
tizenadaptordaliheaderdir = $(devincludepath)/dali/public-api/adaptor-framework
tizenadaptordaliheader_HEADERS = $(tizen_native_buffer_plugin_public_api_header_files) \
- $(capi_native_buffer_plugin_public_api_header_files)
+ $(native_buffer_plugin_public_api_header_files)
# linking test
linker_test_SOURCES = linker-test.cpp
linker_test_CXXFLAGS = \
- -I../../../adaptors/tizen \
- -I../../../capi \
+ -I../../../adaptors/common \
+ -I../../../adaptors/public-api \
$(DALI_ADAPTOR_CFLAGS) \
$(DALICORE_CFLAGS) \
$(DALIX11_CFLAGS) \
#include <dali/public-api/dali-core.h>
-#include <dali/public-api/adaptor-framework/native-buffer-plugin.h>
-#include <dali/public-api/adaptor-framework/common/adaptor.h>
-#include <dali/public-api/adaptor-framework/common/render-surface.h>
-#include <dali/public-api/adaptor-framework/common/orientation.h>
-#include <dali/public-api/adaptor-framework/common/timer.h>
+#include <native-buffer-plugin.h>
+#include <adaptor.h>
+#include <render-surface.h>
+#include <orientation.h>
+#include <timer.h>
using namespace Dali;
$(MMFSOUND_CFLAGS) \
$(FEEDBACK_CFLAGS) \
$(DALI_PROFILE_CFLAGS) \
- -I../../../adaptors/tizen \
+ -I../../../adaptors/public-api \
-Werror -Wall
libdali_feedback_plugin_la_LIBADD = \
+++ /dev/null
-#ifndef __DALI_DOC_H__
-#define __DALI_DOC_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @ingroup CAPI_DALI_MODULE
- * @defgroup CAPI_DALI_ADAPTOR_MODULE Adaptor Framework
- * @section CAPI_DALI_ADAPTOR_MODULE_HEADER Required Header
- * \#include <dali/dali.h>
- * @section CAPI_DALI_ADAPTOR_MODULE_OVERVIEW Overview
- * The adaptor framework provides interfaces onto the platform for Dali.
- * <table> <tr><th>API</th><th>Description</th></tr>
- * <tr><td>@ref Dali::EvasPlugin </td><td>Used by EFL applications that wish to use Dali.</td></tr>
- * <tr><td>@ref Dali::NativeBufferPlugin </td><td>Used by Tizen applications that wish to capture Dali output in a buffer.</td></tr>
- * <tr><td>@ref Dali::AccessibilityManager </td><td>Provides signals for accessibility and screen reader.</td></tr>
- * <tr><td>@ref Dali::Adaptor </td><td>An Adaptor object is used to initialize and control how Dali runs.</td></tr>
- * <tr><td>@ref Dali::ClipboardEventNotifier </td><td>Provides signals when clipboard events are received from the device.</td></tr>
- * <tr><td>@ref Dali::Clipboard </td><td>Interface to the device's clipboard.</td></tr>
- * <tr><td>@ref Dali::DeviceLayout </td><td> The attributes of the screen on the device.</td></tr>
- * <tr><td>@ref Dali::DragAndDropDetector </td><td>The DragAndDropDetector s provides signals when draggable objects are dragged into the Dali window.</td></tr>
- * <tr><td>@ref Dali::HapticPlayer </td><td></td>Plays haptic effects.</tr>
- * <tr><td>@ref Dali::ImfManager </td><td>Interface to the device's Input framework.</td></tr>
- * <tr><td>@ref Dali::Orientation </td><td>Determines the device orientation.</td></tr>
- * <tr><td>@ref Dali::PixmapImage </td><td>Used for displaying native Pixmap images.</td></tr>
- * <tr><td>@ref Dali::RenderSurface </td><td>Interface for a render surface onto which Dali draws.</td></tr>
- * <tr><td>@ref Dali::SoundPlayer </td><td>Class for playing sound effects.</td></tr>
- * <tr><td>@ref Dali::StyleChange </td><td>Class for describing what style information has changed.</td></tr>
- * <tr><td>@ref Dali::StyleMonitor </td><td>Monitors the platform for style changes.</td></tr>
- * <tr><td>@ref Dali::Timer </td><td>Mechanism to issue simple periodic or one-shot events.</td></tr>
- * <tr><td>@ref Dali::TtsPlayer </td><td>Interface to the Text-to-Speech player.</td></tr>
- * <tr><td>@ref Dali::VirtualKeyboard </td><td>Interface to the virtual keyboard.</td></tr>
- * <tr><td>@ref Dali::Window </td><td>The Window class is used for drawing Dali.</td></tr>
- * </table>
- */
+++ /dev/null
-#ifndef __DALI_ACCESSIBILITY_MANAGER_H__
-#define __DALI_ACCESSIBILITY_MANAGER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
-#include <dali/public-api/events/touch-event.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class AccessibilityManager;
-}
-}
-
-class AccessibilityActionHandler;
-class AccessibilityGestureHandler;
-class TouchPoint;
-
-/**
- * @brief The AccessibilityManager provides signals when accessibility & screen reader feature turned on in device.
- */
-class AccessibilityManager : public BaseHandle
-{
-public:
-
- // Typedefs
-
- /**
- * @brief Accessibility Action Signal.
- *
- * Signal connected callback should return the result
- */
- typedef SignalV2< bool ( AccessibilityManager& ) > AccessibilityActionSignalV2; ///< Generic signal type
- typedef SignalV2< bool (AccessibilityManager&, const Dali::TouchEvent&)> AccessibilityActionScrollSignalV2; ///< Scroll signal type
-
- // Signal Names
- static const char* const SIGNAL_STATUS_CHANGED; ///< name "accessibility-status-changed"
- static const char* const SIGNAL_ACTION_NEXT; ///< name "accessibility-action-next"
- static const char* const SIGNAL_ACTION_PREVIOUS; ///< name "accessibility-action-previous"
- static const char* const SIGNAL_ACTION_ACTIVATE; ///< name "accessibility-action-activatae"
- static const char* const SIGNAL_ACTION_OVER; ///< name "accessibility-action-over"
- static const char* const SIGNAL_ACTION_READ; ///< name "accessibility-action-read"
- static const char* const SIGNAL_ACTION_READ_NEXT; ///< name "accessibility-action-read-next"
- static const char* const SIGNAL_ACTION_READ_PREVIOUS; ///< name "accessibility-action-read-prev"
- static const char* const SIGNAL_ACTION_UP; ///< name "accessibility-action-up"
- static const char* const SIGNAL_ACTION_DOWN; ///< name "accessibility-action-down"
- static const char* const SIGNAL_ACTION_CLEAR_FOCUS; ///< name "accessibility-action-clear-focus"
- static const char* const SIGNAL_ACTION_BACK; ///< name "accessibility-action-back"
- static const char* const SIGNAL_ACTION_SCROLL; ///< name "accessibility-action-scroll"
-
- /**
- * @brief Create an uninitialized handle.
- *
- * This can be initialized by calling getting the manager from Dali::Adaptor.
- */
- AccessibilityManager();
-
- /**
- * @brief Retrieve a handle to the AccessibilityManager.
- *
- * @return A handle to the AccessibilityManager.
- */
- static AccessibilityManager Get();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~AccessibilityManager();
-
- /**
- * @brief Returns the current position of the read action.
- * @return The current event position.
- */
- Vector2 GetReadPosition() const;
-
- /**
- * @brief Query whether the accessibility(screen-reader) is enabled.
- *
- * The accessibility will be enabled by system setting.
- * @return True if the accessibility(screen-reader) is enabled.
- */
- bool IsEnabled() const;
-
- /**
- * @brief Set the handler to handle accessibility actions.
- *
- * @param[in] handler The Accessibility action handler.
- * @note Handlers should remove themselves when they are destroyed.
- */
- void SetActionHandler(AccessibilityActionHandler& handler);
-
- /**
- * @brief Set the handler to handle accessibility gestures.
- *
- * @param[in] handler The Accessibility gesture handler.
- * @note Handlers should remove themselves when they are destroyed.
- */
- void SetGestureHandler(AccessibilityGestureHandler& handler);
-
- /**
- * @brief Handle the accessibility action to move focus to the next focusable actor
- * (by one finger flick down).
- *
- * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
- * @return Whether the action is performed successfully or not.
- */
- bool HandleActionNextEvent(bool allowEndFeedback = true);
-
- /**
- * @brief Handle the accessibility action to move focus to the previous focusable actor
- * (by one finger flick up).
- *
- * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
- * @return Whether the action is performed successfully or not.
- */
- bool HandleActionPreviousEvent(bool allowEndFeedback = true);
-
- /**
- * @brief Handle the accessibility action to activate the current focused actor (by one
- * finger double tap)
- *
- * @return Whether the action is performed successfully or not.
- */
- bool HandleActionActivateEvent();
-
- /**
- * @brief Handle the accessibility action to focus and read the actor (by one finger tap or move).
- *
- * @param x x position of event
- * @param y y position of event
- * @param allowReadAgain true if the action read again the same object (i.e. read action)
- * false if the action just read when the focus object is changed (i.e. over action)
- * @return Whether the action is performed successfully or not.
- */
- bool HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain);
-
- /**
- * @brief Handle the accessibility action to move focus to the next focusable actor
- * (by one finger flick right).
- *
- * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
- * @return Whether the action is performed successfully or not.
- */
- bool HandleActionReadNextEvent(bool allowEndFeedback = true);
-
- /**
- * @brief Handle the accessibility action to move focus to the previous focusable actor
- * (by one finger flick up).
- *
- * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the front
- * @return Whether the action is performed successfully or not.
- */
- bool HandleActionReadPreviousEvent(bool allowEndFeedback = true);
-
- /**
- * @brief Handle the accessibility action to change the value when the current focused
- * actor is a slider (by double finger down and move up and right).
- *
- * @return Whether the action is performed successfully or not.
- */
- bool HandleActionUpEvent();
-
- /**
- * @brief Handle the accessibility action to change the value when the current focused
- * actor is a slider (by double finger down and move down and left).
- *
- * @return Whether the action is performed successfully or not.
- */
- bool HandleActionDownEvent();
-
- /**
- * @brief Handle the accessibility action to clear the focus from the current focused
- * actor if any, so that no actor is focused in the focus chain.
- *
- * @return Whether the action is performed successfully or not.
- */
- bool HandleActionClearFocusEvent();
-
- /**
- * @brief Handle the accessibility action to scroll when there is a scroller on the touched position
- * (by 2 finger touch & move, 2 finger flick).
- *
- * @param[in] point The touch point information.
- * @param[in] timeStamp The time the touch occurred.
- * @return Whether the action is performed successfully or not.
- */
- bool HandleActionScrollEvent(const TouchPoint& point, unsigned long timeStamp);
-
- /**
- * @brief Handle the accessibility action to move for the current focused actor
- * (by 1 finger tap & hold and move).
- *
- * @param[in] point The touch point information.
- * @param[in] timeStamp The time the touch occurred.
- * @return Whether the action is performed successfully or not.
- */
- bool HandleActionTouchEvent(const TouchPoint& point, unsigned long timeStamp);
-
- /**
- * @brief Handle the accessibility action to navigate back (by two fingers circle draw).
- * @return Whether the action is performed successfully or not.
- */
- bool HandleActionBackEvent();
-
- /**
- * @brief Handle the accessibility action to enable the feature.
- */
- void HandleActionEnableEvent();
-
- /**
- * @brief Handle the accessibility action to disable the feature.
- */
- void HandleActionDisableEvent();
-
-public: // Signals
-
- /**
- * @brief This is emitted when accessibility(screen-reader) feature turned on or off.
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionSignalV2& StatusChangedSignal();
-
- /**
- * @brief This is emitted when accessibility action is received to move focus to the next
- * focusable actor (by one finger flick down).
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionSignalV2& ActionNextSignal();
-
- /**
- * @brief This is emitted when accessibility action is received to move focus to the previous
- * focusable actor (by one finger flick up).
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionSignalV2& ActionPreviousSignal();
-
- /**
- * @brief This is emitted when accessibility action is received to activate the current focused
- * actor (by one finger double tap).
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionSignalV2& ActionActivateSignal();
-
- /**
- * @brief This is emitted when accessibility action is received to focus and read the actor
- * (by one finger tap).
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionSignalV2& ActionReadSignal();
-
- /**
- * @brief This is emitted when accessibility action is received to focus and read the actor
- * (by one finger move).
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionSignalV2& ActionOverSignal();
-
- /**
- * @brief This is emitted when accessibility action is received to move focus to the next
- * focusable actor (by one finger flick right).
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionSignalV2& ActionReadNextSignal();
-
- /**
- * @brief This is emitted when accessibility action is received to move focus to the previous
- * focusable actor (by one finger flick left).
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionSignalV2& ActionReadPreviousSignal();
-
- /**
- * @brief This is emitted when accessibility action is received to change the value when the
- * current focused actor is a slider (by double finger down and move up and right).
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionSignalV2& ActionUpSignal();
-
- /**
- * @brief This is emitted when accessibility action is received to change the value when the
- * current focused actor is a slider (by double finger down and move down and left).
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionSignalV2& ActionDownSignal();
-
- /**
- * @brief This is emitted when accessibility action is received to clear the focus from the
- * current focused actor if any, so that no actor is focused in the focus chain.
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionSignalV2& ActionClearFocusSignal();
-
- /**
- * @brief This is emitted when accessibility action is received to navigate back (by two
- * fingers circle draw).
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionSignalV2& ActionBackSignal();
-
- /**
- * @brief This is emitted when accessibility action is received to handle scroll event (by two
- * fingers drag).
- *
- * A callback of the following type may be connected:
- * @code
- * bool YourCallback( AccessibilityManager& manager, const TouchEvent& event );
- * @endcode
- * @return The signal to connect to.
- */
- AccessibilityActionScrollSignalV2& ActionScrollSignal();
-
-public: // Not intended for application developers
-
- /**
- * @brief Creates a handle using the Adaptor::Internal implementation.
- *
- * @param[in] manager The AccessibilityManager implementation.
- */
- AccessibilityManager( Internal::Adaptor::AccessibilityManager& manager );
-
- /**
- * @brief This constructor is used by AccessibilityManager::Get().
- *
- * @param[in] manager A pointer to the accessibility manager.
- */
- AccessibilityManager( Internal::Adaptor::AccessibilityManager* manager );
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_ACCESSIBILITY_MANAGER_H__
+++ /dev/null
-#ifndef __DALI_ADAPTOR_H__
-#define __DALI_ADAPTOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-#include <dali/public-api/adaptor-framework/common/window.h>
-#include <dali/public-api/adaptor-framework/common/tts-player.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/events/touch-event.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-struct DeviceLayout;
-class RenderSurface;
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class Adaptor;
-}
-}
-
-/**
- * @brief An Adaptor object is used to initialize and control how Dali runs.
- *
- * It provides a lifecycle interface that allows the application
- * writer to provide their own main loop and other platform related
- * features.
- *
- * The Adaptor class provides a means for initialising the resources required by the Dali::Core.
- *
- * When dealing with platform events, the application writer MUST ensure that Dali is called in a
- * thread-safe manner.
- *
- * As soon as the Adaptor class is created and started, the application writer can initialise their
- * Dali::Actor objects straight away or as required by the main loop they intend to use (there is no
- * need to wait for an initialise signal as per the Dali::Application class).
- *
- * The Adaptor does emit a Resize signal which informs the user when the surface is resized.
- * Tizen and Linux Adaptors should follow the example below:
- *
- * @code
- * void CreateProgram(DaliAdaptor& adaptor)
- * {
- * // Create Dali components...
- * // Can instantiate adaptor here instead, if required
- * }
- *
- * int main ()
- * {
- * // Initialise platform
- * MyPlatform.Init();
- *
- * // Create an 800 by 1280 window positioned at (0,0).
- * Dali::PositionSize positionSize(0, 0, 800, 1280);
- * Dali::Window window = Dali::Window::New( positionSize, "My Application" );
- *
- * // Create an adaptor which uses that window for rendering
- * Dali::Adaptor adaptor = Dali::Adaptor::New( window );
- * adaptor.Start();
- *
- * CreateProgram(adaptor);
- * // Or use this as a callback function depending on the platform initialisation sequence.
- *
- * // Start Main Loop of your platform
- * MyPlatform.StartMainLoop();
- *
- * return 0;
- * }
- * @endcode
- *
- * If required, you can also connect class member functions to a signal:
- *
- * @code
- * MyApplication application;
- * adaptor.ResizedSignal().Connect(&application, &MyApplication::Resize);
- * @endcode
- *
- * @see RenderSurface
- */
-class Adaptor
-{
-public:
-
- typedef SignalV2< void (Adaptor&) > AdaptorSignalV2; ///< Generic Type for adaptor signals
-
-public:
- /**
- * @brief Create a new adaptor using the window.
- *
- * @param[in] window The window to draw onto
- * @note The default base layout DeviceLayout::DEFAULT_BASE_LAYOUT will be used.
- * @return a reference to the adaptor handle
- */
- static Adaptor& New( Window window );
-
- /**
- * @brief Create a new adaptor using the window.
- *
- * @param[in] window The window to draw onto
- * @param[in] baseLayout The base layout that the application has been written for
- * @return a reference to the adaptor handle
- */
- static Adaptor& New( Window window, const DeviceLayout& baseLayout );
-
- /**
- * @brief Virtual Destructor.
- */
- virtual ~Adaptor();
-
-public:
-
- /**
- * @brief Starts the Adaptor.
- */
- void Start();
-
- /**
- * @brief Pauses the Adaptor.
- */
- void Pause();
-
- /**
- * @brief Resumes the Adaptor, if previously paused.
- *
- * @note If the adaptor is not paused, this does not do anything.
- */
- void Resume();
-
- /**
- * @brief Stops the Adaptor.
- */
- void Stop();
-
- /**
- * @brief Ensures that the function passed in is called from the main loop when it is idle.
- *
- * A callback of the following type may be used:
- * @code
- * void MyFunction();
- * @endcode
- *
- * @param[in] callBack The function to call.
- * @return true if added successfully, false otherwise
- */
- bool AddIdle( boost::function<void(void)> callBack );
-
- /**
- * @brief Get the render surface the adaptor is using to render to.
- *
- * @return reference to current render surface
- */
- RenderSurface& GetSurface();
-
- /**
- * @brief Returns a reference to the instance of the adaptor used by the current thread.
- *
- * @return A reference to the adaptor.
- * @pre The adaptor has been initialised.
- * @note This is only valid in the main thread.
- */
- static Adaptor& Get();
-
- /**
- * @brief Checks whether the adaptor is available.
- *
- * @return true, if it is available, false otherwise.
- */
- static bool IsAvailable();
-
- /**
- * @brief Registers the singleton of Dali handle with its type info.
- *
- * The singleton will be kept alive for the life time of the
- * adaptor.
- * @note This is not intended for application developers.
- * @param[in] info The type info of the Dali handle generated by the compiler.
- * @param[in] singleton The Dali handle to be registered
- */
- void RegisterSingleton(const std::type_info& info, BaseHandle singleton);
-
- /**
- * @brief Gets the singleton for the given type.
- *
- * @note This is not intended for application developers.
- * @param[in] info The type info of the given type.
- * @return the Dali handle if it is registered as a singleton or an uninitialized handle.
- */
- BaseHandle GetSingleton(const std::type_info& info) const;
-
- /**
- * @brief Call this method to notify Dali when the system language changes.
- *
- * Use this only when NOT using Dali::Application, As Application created using
- * Dali::Application will automatically receive notification of language change.
- * When Dali::Application is not used, the application developer should
- * use app-core to receive language change notifications and should update Dali
- * by calling this method.
- */
- void NotifyLanguageChanged();
-
- /**
- * @brief Sets minimum distance in pixels that the fingers must move towards/away from each other in order to
- * trigger a pinch gesture
- *
- * @param[in] distance The minimum pinch distance in pixels
- */
- void SetMinimumPinchDistance(float distance);
-
-public: // Signals
-
- /**
- * @brief The user should connect to this signal if they need to perform any
- * special activities when the surface Dali is being rendered on is resized.
- *
- * @return The signal to connect to
- */
- AdaptorSignalV2& ResizedSignal();
-
- /**
- * @brief This signal is emitted when the language is changed on the device.
- *
- * @return The signal to connect to
- */
- AdaptorSignalV2& LanguageChangedSignal();
-
-private:
-
- // Undefined
- Adaptor(const Adaptor&);
- Adaptor& operator=(Adaptor&);
-
-private:
-
- /**
- * @brief Create an uninitialized Adaptor.
- */
- DALI_INTERNAL Adaptor();
-
- Internal::Adaptor::Adaptor* mImpl; ///< Implementation object
- friend class Internal::Adaptor::Adaptor;
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_ADAPTOR_H__
+++ /dev/null
-#ifndef __DALI_CLIPBOARD_EVENT_NOTIFIER_H__
-#define __DALI_CLIPBOARD_EVENT_NOTIFIER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class ClipboardEventNotifier;
-}
-}
-
-/**
- * @brief The ClipboardEventNotifier provides signals when clipboard events are received from the device.
- */
-class ClipboardEventNotifier : public BaseHandle
-{
-public:
-
- // Typedefs
-
- /**
- * @brief Clipboard event
- */
- typedef SignalV2< void ( ClipboardEventNotifier& ) > ClipboardEventSignalV2;
-
- // Signal Names
- static const char* const SIGNAL_CONTENT_SELECTED; ///< name "content-selected"
-
- /**
- * @brief Create an uninitialized handle.
- *
- * This can be initialized by getting the notifier from Dali::Adaptor.
- */
- ClipboardEventNotifier();
-
- /**
- * @brief Retrieve a handle to the ClipboardEventNotifier instance.
- *
- * @return A handle to the ClipboardEventNotifier
- */
- static ClipboardEventNotifier Get();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~ClipboardEventNotifier();
-
- /**
- * @brief Returns the selected content.
- * @return A reference to the string representing the selected content.
- */
- const std::string& GetContent() const;
-
- /**
- * @brief Sets the selected content.
- * @param[in] content A string that represents the content that has been selected.
- */
- void SetContent( const std::string& content );
-
- /**
- * @brief Clears the stored content.
- */
- void ClearContent();
-
- /**
- * @brief Called when content is selected in the clipboard.
- */
- void EmitContentSelectedSignal();
-
-public: // Signals
-
- /**
- * @brief This is emitted when content is selected from the clipboard.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallback( ClipboardEventNotifier& notifier );
- * @endcode
- * @return The signal to connect to.
- */
- ClipboardEventSignalV2& ContentSelectedSignal();
-
-public: // Not intended for application developers
-
- /**
- * @brief This constructor is used by ClipboardEventNotifier::Get().
- *
- * @param[in] notifier A pointer to the drag and drop notifier.
- */
- ClipboardEventNotifier( Internal::Adaptor::ClipboardEventNotifier* notifier );
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_CLIPBOARD_EVENT_NOTIFIER_H__
+++ /dev/null
-#ifndef __DALI_CLIPBOARD_H__
-#define __DALI_CLIPBOARD_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/object/base-handle.h>
-
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-
-namespace Adaptor
-{
-class Clipboard;
-}
-}
-
-/**
- * @brief Interface to the device's clipboard.
- *
- * Clipboard can manage it's item and set show / hide status.
- */
-
-class Clipboard : public BaseHandle
-{
-public:
- /**
- * @brief Create an uninitialized Clipboard.
- *
- * this can be initialized with one of the derived Clipboard' New() methods
- */
- Clipboard();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~Clipboard();
-
- /**
- * @brief This constructor is used by Adaptor::GetClipboard().
- *
- * @param[in] clipboard A pointer to the clipboard.
- */
- Clipboard( Internal::Adaptor::Clipboard* clipboard );
-
- /**
- * @brief Retrieve a handle to the ClipboardEventNotifier instance.
- *
- * @return A handle to the Clipboard
- */
- static Clipboard Get();
-
- /**
- * @brief Send the given string to the clipboard.
- *
- * @param[in] itemData string to send to clip board
- * @return bool true if the internal clip board sending was successful.
- */
- bool SetItem( const std::string& itemData );
-
- /**
- * @brief Retreive the string at the given index in the clipboard.
- *
- * @param[in] index item in clipboard list to retrieve
- * @return string the text item at the current index.
- */
- std::string GetItem( unsigned int index );
-
- /**
- * @brief Returns the number of item currently in the clipboard.
- *
- * @return unsigned int number of clipboard items
- */
- unsigned int NumberOfItems();
-
- /**
- * @brief Show the clipboard window.
- */
- void ShowClipboard();
-
- /**
- * @brief Hide the clipboard window.
- */
- void HideClipboard();
-
-};
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_CLIPBOARD_H__
+++ /dev/null
-#ifndef __DALI_DEVICE_LAYOUT_H__
-#define __DALI_DEVICE_LAYOUT_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/math/vector2.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-/**
- * @brief The attributes of the screen on the device.
- *
- * An application can specify the base layout that they used by inputting the values in this
- * structure and passing it to the Application or Adaptor class.
- * @see Dali::Application::Application(* argc, char **argv[], DeviceLayout baseLayout)
- * @see Dali::Adaptor::Adaptor(RenderSurface& surface, DeviceLayout baseLayout)
- */
-struct DeviceLayout
-{
-public: // Construction & Destruction
-
- /**
- * @brief Default Constructor.
- */
- DeviceLayout();
-
- /**
- * @brief Create a DeviceLayout with specific parameters.
- * @param[in] resolution The resolution of the screen the application is based upon.
- * @param[in] screenSize The size of the screen the application is based upon.
- * @param[in] dpi The DPI of the screen the application is based upon.
- * @param[in] viewingDistance The default viewing distance of the screen the application is based upon.
- */
- DeviceLayout(Vector2 resolution, float screenSize, Vector2 dpi, float viewingDistance);
-
- /**
- * @brief Destructor.
- */
- ~DeviceLayout();
-
-public: // Data
-
- Vector2 resolution; ///< Resolution (width and height) of the screen.
- float screenSize; ///< Size of the screen in inches (diagonal size).
- Vector2 dpi; ///< DPI (Dots per Inch) of the screen on the device (x & y).
- float viewingDistance; ///< Average distance between the user and the device.
-
-public: // Defaults Layouts
-
- /**
- * @brief This is the default base layout that Dali will assume if no layout is passed in from the
- * application.
- *
- * Resolution: 720.0f x 1280.0f
- * Screen Size: 4.65f
- * DPI: 316.0f x 316.0f
- * Viewing Distance: 30.0f
- */
- static const DeviceLayout DEFAULT_BASE_LAYOUT;
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_DEVICE_LAYOUT_H__
+++ /dev/null
-#ifndef __DALI_DRAG_AND_DROP_DETECTOR_H__
-#define __DALI_DRAG_AND_DROP_DETECTOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class DragAndDropDetector;
-}
-}
-
-/**
- * @brief The DragAndDropDetector%s provides signals when draggable objects are dragged into our window.
- * It provides signals for when the draggable object enters our window, moves around in our window,
- * leaves our window and when it is finally dropped into our window.
- * The basic usage is shown below:
- *
- * @code
- *
- * void Example()
- * {
- * DragAndDropDetector detector( window::GetDragAndDropDetector() );
- *
- * // Get notifications when the draggable item enters our window
- * detector.EnteredSignal().Connect( &OnEntered );
- *
- * // Get notifications when the draggable item leaves our window
- * detector.ExitedSignal().Connect( &OnExited );
- *
- * // Get notifications when the draggable item is moved within our window
- * detector.MovedSignal().Connect( &OnMoved );
- *
- * // Get notifications when the draggable item is dropped
- * detector.DroppedSignal().Connect( &OnDropped );
- * }
- *
- * void OnEntered( DragAndDropDetector detector )
- * {
- * // Change mode as required
- * }
- *
- * void OnExited( DragAndDropDetector detector )
- * {
- * // Change mode as required
- * }
- *
- * void OnMoved( DragAndDropDetector detector )
- * {
- * // Query the new values
- * std::cout << "Position = " << detector.GetCurrentScreenPosition() << std::endl;
- * }
- *
- * void OnDropped( DragAndDropDetector detector )
- * {
- * // Query the new values
- * std::cout << "Position = " << detector.GetCurrentScreenPosition() << ", Content = " << detector.GetContent() << std::endl;
- * }
- *
- * @endcode
- */
-class DragAndDropDetector : public BaseHandle
-{
-public:
-
- // Typedefs
-
- /**
- * @brief Drag & Drop signal.
- */
- typedef SignalV2< void ( DragAndDropDetector ) > DragAndDropSignalV2;
-
- // Signal Names
- static const char* const SIGNAL_ENTERED;///< name "drag-and-drop-entered"
- static const char* const SIGNAL_EXITED; ///< name "drag-and-drop-exited"
- static const char* const SIGNAL_MOVED; ///< name "drag-and-drop-moved"
- static const char* const SIGNAL_DROPPED;///< name "drag-and-drop-dropped"
-
- /**
- * @brief Create an uninitialized handle.
- *
- * This can be initialized by calling getting the detector from Dali::Window.
- */
- DragAndDropDetector();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~DragAndDropDetector();
-
- /**
- * @brief Returns the dropped content.
- *
- * @return A reference to the string representing the dropped content.
- */
- const std::string& GetContent() const;
-
- /**
- * @brief Returns the current position of the dragged object.
- *
- * This is the dropped position when an object is dropped.
- * @return The current screen position.
- */
- Vector2 GetCurrentScreenPosition() const;
-
-public: // Signals
-
- /**
- * @brief This is emitted when a dragged object enters a DALi window.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallback( DragAndDropDetector detector );
- * @endcode
- * @return The signal to connect to.
- */
- DragAndDropSignalV2& EnteredSignal();
-
- /**
- * @brief This is emitted when a dragged object leaves a DALi window.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallback( DragAndDropDetector detector );
- * @endcode
- * @return The signal to connect to.
- */
- DragAndDropSignalV2& ExitedSignal();
-
- /**
- * @brief This is emitted when a dragged object is moved within the DALi window.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallback( DragAndDropDetector detector );
- * @endcode
- * This will be replaced by a property notification system once that is in place.
- * @return The signal to connect to.
- */
- DragAndDropSignalV2& MovedSignal();
-
- /**
- * @brief This is emitted when a dragged object is dropped within a DALi window.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallback( DragAndDropDetector detector );
- * @endcode
- * @return The signal to connect to.
- */
- DragAndDropSignalV2& DroppedSignal();
-
-public: // Not intended for application developers
-
- /**
- * @brief This constructor is used by DragAndDropDetector::Get().
- *
- * @param[in] detector A pointer to the drag and drop detector.
- */
- DragAndDropDetector( Internal::Adaptor::DragAndDropDetector* detector );
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_DRAG_AND_DROP_DETECTOR_H__
+++ /dev/null
-#ifndef __DALI_HAPTIC_PLAYER_H__
-#define __DALI_HAPTIC_PLAYER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-handle.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class HapticPlayer;
-}
-}
-
-/**
- * @brief Plays haptic effects.
- */
-class HapticPlayer : public BaseHandle
-{
-public:
-
- /**
- * @brief Create an uninitialized handle.
- *
- * This can be initialized by calling HapticPlayer::Get().
- */
- HapticPlayer();
-
- /**
- * @brief Create an initialized handle to the HapticPlayer.
- *
- * @return A handle to a newly allocated Dali resource.
- */
- static HapticPlayer Get();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~HapticPlayer();
-
- /**
- * @brief Plays a monotone vibration.
- * @param[in] duration The duration of the vibration.
- */
- void PlayMonotone(unsigned int duration);
-
- /**
- * @brief Plays vibration in predefined patterns.
- * @param[in] filePath Path to the file containing the effect.
- */
- void PlayFile(const std::string filePath);
-
- /**
- * @brief Stops the currently playing vibration effects.
- */
- void Stop();
-
-public: // Not intended for application developers
-
- /**
- * @brief This constructor is used by HapticPlayer::Get().
- * @param[in] hapticPlayer A pointer to the haptic player.
- */
- HapticPlayer( Internal::Adaptor::HapticPlayer* hapticPlayer );
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_HAPTIC_PLAYER_H__
+++ /dev/null
-#ifndef IMFMANAGER_H
-#define IMFMANAGER_H
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class ImfManager;
-}
-}
-
-// TODO: Temporary patch to hidden ecore dependency. Must fix it.
-typedef void* ImfContext;
-
-/**
- * @brief The ImfManager class
- *
- * Specifically manages the ecore input method framework which enables the virtual or hardware keyboards.
- */
-class ImfManager : public BaseHandle
-{
-public:
-
- /**
- * @brief Events that are generated by the IMF.
- */
- enum ImfEvent
- {
- VOID, ///< No event
- PREEDIT, ///< Pre-Edit changed
- COMMIT, ///< Commit recieved
- DELETESURROUNDING, ///< Event to delete a range of characters from the string
- GETSURROUNDING ///< Event to query string and cursor position
- };
-
- /**
- * @brief This structure is used to pass on data from the IMF regarding predictive text.
- */
- struct ImfEventData
- {
- /**
- * @brief Default Constructor.
- */
- ImfEventData()
- : eventName( VOID ),
- predictiveString(""),
- cursorOffset( 0 ),
- numberOfChars ( 0 )
- {
- };
-
- /**
- * @brief Constructor
- *
- * @param[in] aEventName The name of the event from the IMF.
- * @param[in] aPredictiveString The pre-edit or commit string.
- * @param[in] aCursorOffset Start position from the current cursor position to start deleting characters.
- * @param[in] aNumberOfChars The number of characters to delete from the cursorOffset.
- */
- ImfEventData(ImfEvent aEventName, const std::string& aPredictiveString, int aCursorOffset,int aNumberOfChars )
- : eventName(aEventName), predictiveString(aPredictiveString), cursorOffset( aCursorOffset ), numberOfChars( aNumberOfChars )
- {
- }
-
- // Data
- ImfEvent eventName; ///< The name of the event from the IMF.
- std::string predictiveString; ///< The pre-edit or commit string.
- int cursorOffset; ///< Start position from the current cursor position to start deleting characters.
- int numberOfChars; ///< number of characters to delete from the cursorOffset.
- };
-
- /**
- * @brief Data required by IMF from the callback
- */
- struct ImfCallbackData
- {
- /**
- * @brief Constructor
- */
- ImfCallbackData( )
- : update( false ), cursorPosition( 0 ), preeditResetRequired ( false )
- {
- }
-
- /**
- * @brief Constructor
- * @param[in] aUpdate True if cursor position needs to be updated
- * @param[in] aCursorPosition new position of cursor
- * @param[in] aCurrentText current text string
- * @param[in] aPreeditResetRequired flag if preedit reset is required.
- */
- ImfCallbackData(bool aUpdate, int aCursorPosition, std::string aCurrentText, bool aPreeditResetRequired )
- : update(aUpdate), cursorPosition(aCursorPosition), currentText( aCurrentText ), preeditResetRequired( aPreeditResetRequired )
- {
- }
-
- bool update; ///< if cursor position needs to be updated
- int cursorPosition; ///< new position of cursor
- std::string currentText; ///< current text string
- bool preeditResetRequired; ///< flag if preedit reset is required.
- };
-
- typedef SignalV2< void (ImfManager&) > ImfManagerSignalV2; ///< Keyboard actived signal
-
- typedef SignalV2< ImfCallbackData ( ImfManager&, const ImfEventData& ) > ImfEventSignalV2; ///< keyboard events
-
-public:
-
- /**
- * @brief Retrieve a handle to the instance of ImfManager.
- * @return A handle to the ImfManager.
- */
- static ImfManager Get();
-
- /**
- * @brief Get the current imf context.
- * @return current imf context.
- */
- ImfContext GetContext();
-
- /**
- * @brief Activate the IMF.
- *
- * It means that the text editing is started at somewhere.
- * If the H/W keyboard isn't connected then it will show the virtual keyboard.
- */
- void Activate();
-
- /**
- * @brief Deactivate the IMF.
- *
- * It means that the text editing is finished at somewhere.
- */
- void Deactivate();
-
- /**
- * @brief Get the restoration status, which controls if the keyboard is restored after the focus lost then regained.
- *
- * If true then keyboard will be restored (activated) after focus is regained.
- * @return restoration status.
- */
- bool RestoreAfterFocusLost() const;
-
- /**
- * @brief Set status whether the IMF has to restore the keyboard after losing focus.
- *
- * @param[in] toggle True means that keyboard should be restored after focus lost and regained.
- */
- void SetRestoreAferFocusLost( bool toggle );
-
- /**
- * @brief Send message reset the pred-edit state / imf module.
- *
- * Used to interupt pre-edit state maybe due to a touch input.
- */
- void Reset();
-
- /**
- * @brief Notifies IMF context that the cursor position has changed, required for features like auto-capitalisation.
- */
- void NotifyCursorPosition();
-
- /**
- * @brief Sets cursor position stored in VirtualKeyboard, this is required by the IMF context.
- *
- * @param[in] cursorPosition position of cursor
- */
- void SetCursorPosition( unsigned int cursorPosition );
-
- /**
- * @brief Gets cursor position stored in VirtualKeyboard, this is required by the IMF context.
- *
- * @return current position of cursor
- */
- int GetCursorPosition();
-
- /**
- * @brief Method to store the string required by the IMF, this is used to provide predictive word suggestions.
- *
- * @param[in] text The text string surrounding the current cursor point.
- */
- void SetSurroundingText( std::string text );
-
- /**
- * @brief Gets current text string set within the IMF manager, this is used to offer predictive suggestions.
- *
- * @return current position of cursor
- */
- std::string GetSurroundingText();
-
-public:
-
- // Signals
-
- /**
- * @brief This is emitted when the virtual keyboard is connected to or the hardware keyboard is activated.
- *
- * @return The IMF Activated signal.
- */
- ImfManagerSignalV2& ActivatedSignal();
-
- /**
- * @brief This is emitted when the IMF manager receives an event from the IMF.
- *
- * @return The Event signal containing the event data.
- */
- ImfEventSignalV2& EventReceivedSignal();
-
- // Construction & Destruction
-
- /**
- * @brief Constructor.
- */
- ImfManager();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~ImfManager();
-
- /**
- * @brief This constructor is used by ImfManager::Get().
- *
- * @param[in] imfManager A pointer to the imf Manager.
- */
- ImfManager( Internal::Adaptor::ImfManager* imfManager );
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // IMFMANAGER_H
+++ /dev/null
-#ifndef __DALI_KEY_H__
-#define __DALI_KEY_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-
-#include <dali/public-api/events/key-event.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-/**
- * @brief Mapping of keyboard and mouse button event keycodes to platform specific codes.
- *
- * For tizen the X Server Keycode is used as reference, unless it's over ridden
- * in utilX.h in which case the values are based on utilX.h
- */
-
-typedef int KEY;
-
-extern const KEY DALI_KEY_INVALID;
-extern const KEY DALI_KEY_ESCAPE;
-extern const KEY DALI_KEY_BACK;
-extern const KEY DALI_KEY_CAMERA;
-extern const KEY DALI_KEY_CONFIG;
-extern const KEY DALI_KEY_POWER;
-extern const KEY DALI_KEY_PAUSE;
-extern const KEY DALI_KEY_CANCEL;
-extern const KEY DALI_KEY_PLAY_CD;
-extern const KEY DALI_KEY_STOP_CD;
-extern const KEY DALI_KEY_PAUSE_CD;
-extern const KEY DALI_KEY_NEXT_SONG;
-extern const KEY DALI_KEY_PREVIOUS_SONG;
-extern const KEY DALI_KEY_REWIND;
-extern const KEY DALI_KEY_FASTFORWARD;
-extern const KEY DALI_KEY_MEDIA;
-extern const KEY DALI_KEY_PLAY_PAUSE;
-extern const KEY DALI_KEY_MUTE;
-extern const KEY DALI_KEY_SEND;
-extern const KEY DALI_KEY_SELECT;
-extern const KEY DALI_KEY_END;
-extern const KEY DALI_KEY_MENU;
-extern const KEY DALI_KEY_HOME;
-extern const KEY DALI_KEY_HOMEPAGE;
-extern const KEY DALI_KEY_WEBPAGE;
-extern const KEY DALI_KEY_MAIL;
-extern const KEY DALI_KEY_SCREENSAVER;
-extern const KEY DALI_KEY_BRIGHTNESS_UP;
-extern const KEY DALI_KEY_BRIGHTNESS_DOWN;
-extern const KEY DALI_KEY_SOFT_KBD;
-extern const KEY DALI_KEY_QUICK_PANEL;
-extern const KEY DALI_KEY_TASK_SWITCH;
-extern const KEY DALI_KEY_APPS;
-extern const KEY DALI_KEY_SEARCH;
-extern const KEY DALI_KEY_VOICE;
-extern const KEY DALI_KEY_LANGUAGE;
-extern const KEY DALI_KEY_VOLUME_UP;
-extern const KEY DALI_KEY_VOLUME_DOWN;
-
-/**
- * @brief Check if a key event is for a specific DALI KEY.
- *
- * @param keyEvent reference to a keyEvent structure
- * @param daliKey dali key enum
- * @return true if the key is matched, false if not
- */
-bool IsKey( const KeyEvent& keyEvent, KEY daliKey);
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_KEY_H__
+++ /dev/null
-#ifndef __DALI_ORIENTATION_H__
-#define __DALI_ORIENTATION_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-
-#include <dali/public-api/signals/dali-signal-v2.h>
-#include <dali/public-api/object/base-handle.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class Orientation;
-}
-}
-
-/**
- * @brief Orientation allows the user to determine the orientation of the device.
- *
- * A signal is emitted whenever the orientation changes.
- * Dali applications have full control over visual layout when the device is rotated
- * i.e. the application developer decides which UI controls to rotate, if any.
- */
-class Orientation : public BaseHandle
-{
-public:
-
- typedef SignalV2< void (Orientation) > OrientationSignalV2; ///< Orientation changed signal type
-
- /**
- * @brief Create an unintialized handle.
- *
- * This can be initialized by calling Dali::Application::GetOrientation()
- */
- Orientation();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~Orientation();
-
- /**
- * @copydoc Dali::BaseHandle::operator=
- */
- using BaseHandle::operator=;
-
-
- /**
- * @brief Returns the orientation of the device in degrees.
- *
- * This is one of four discrete values, in degrees clockwise: 0, 90, 180, & 270
- * For a device with a portrait form-factor:
- * 0 indicates that the device is in the "normal" portrait orientation.
- * 90 indicates that device has been rotated clockwise, into a landscape orientation.
- * @return The orientation in degrees clockwise.
- */
- int GetDegrees() const;
-
- /**
- * @brief Returns the orientation of the device in radians.
- *
- * This is one of four discrete values, in radians clockwise: 0, PI/2, PI, & 3xPI/2
- * For a device with a portrait form-factor:
- * 0 indicates that the device is in the "normal" portrait orientation.
- * PI/2 indicates that device has been rotated clockwise, into a landscape orientation.
- * @return The orientation in radians clockwise.
- */
- float GetRadians() const;
-
- /**
- * @brief The user should connect to this signal so that they can be notified whenever
- * the orientation of the device changes.
- *
- * @return The orientation change signal.
- */
- OrientationSignalV2& ChangedSignal();
-
-public: // Not intended for application developers
- /**
- * @brief This constructor is used by Dali::Application::GetOrientation().
- *
- * @param[in] orientation A pointer to the orientation object
- */
- explicit DALI_INTERNAL Orientation( Internal::Adaptor::Orientation* orientation );
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_ORIENTATION_H__
+++ /dev/null
-#ifndef __DALI_PIXMAP_IMAGE_H__
-#define __DALI_PIXMAP_IMAGE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/images/native-image.h>
-#include <dali/public-api/object/any.h>
-
-namespace Dali DALI_IMPORT_API
-{
-class Adaptor;
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class PixmapImage;
-}
-}
-
-class PixmapImage;
-/**
- * @brief Pointer to Dali::PixmapImage.
- */
-typedef IntrusivePtr<PixmapImage> PixmapImagePtr;
-
-/**
- * @brief Used for displaying native Pixmap images.
- *
- * The native pixmap can be created internally or
- * externally by X11 or ECORE-X11.
- *
- */
-class PixmapImage : public NativeImage
-{
-public:
-
- /**
- * @brief PixmapImage can use pixmaps created by X11 or ECORE X11.
- */
- enum PixmapAPI
- {
- X11, ///< X types
- ECORE_X11, ///< EFL e-core x11 types
- };
-
- /**
- * @brief When creating a pixmap the color depth has to be specified.
- */
- enum ColorDepth
- {
- COLOR_DEPTH_DEFAULT, ///< Uses the current X screen default depth (recommended)
- COLOR_DEPTH_8, ///< 8 bits per pixel
- COLOR_DEPTH_16, ///< 16 bits per pixel
- COLOR_DEPTH_24, ///< 24 bits per pixel
- COLOR_DEPTH_32 ///< 32 bits per pixel
- };
-
- /**
- * @brief Create a new PixmapImage.
- *
- * Depending on hardware the width and height may have to be a power of two.
- * @param[in] width The width of the image.
- * @param[in] height The height of the image.
- * @param[in] depth color depth of the pixmap
- * @param[in] adaptor reference to dali adaptor
- * @return A smart-pointer to a newly allocated image.
- */
- static PixmapImagePtr New( unsigned int width, unsigned int height, ColorDepth depth, Adaptor& adaptor );
-
- /**
- * @brief Create a new PixmapImage from an existing pixmap.
- *
- * @param[in] pixmap must be a X11 pixmap or a Ecore_X_Pixmap
- * @param[in] adaptor reference to dali adaptor
- * @return A smart-pointer to a newly allocated image.
- */
- static PixmapImagePtr New( Any pixmap, Adaptor& adaptor );
-
- /**
- * @brief Retrieve the internal pixmap
- *
- * @param api whether to return a pixmap that can be used with X11 or EFL
- * @return pixmap any object containing a pixmap of the type specified PixmapAPI
- */
- Any GetPixmap( PixmapAPI api );
-
- /**
- * @brief Retrieve the display used to create the pixmap.
- *
- * If the pixmap was created outside of Dali, then this display
- * is the one Dali uses internally.
- * @return Any object containing the display
- */
- Any GetDisplay();
-
- /**
- * @brief Get a copy of the pixels used by PixmapImage.
- *
- * This is only supported for 24 bit RGB and 32 bit RGBA internal formats
- * (COLOR_DEPTH_24 and COLOR_DEPTH_32).
- * @param[out] pixbuf a vector to store the pixels in
- * @param[out] width width of image
- * @param[out] height height of image
- * @param[out] pixelFormat pixel format used by image
- * @return True if the pixels were gotten, and false otherwise.
- */
- bool GetPixels( std::vector<unsigned char>& pixbuf, unsigned int& width, unsigned int& height, Pixel::Format& pixelFormat ) const;
-
- /**
- * @brief Convert the current pixel contents to either a JPEG or PNG format
- * and write that to the filesytem.
- *
- * @param[in] filename Identify the filesytem location at which to write the
- * encoded image. The extension determines the encoding used.
- * The two valid encoding are (".jpeg"|".jpg") and ".png".
- * @return True if the pixels were written, and false otherwise.
- */
- bool EncodeToFile(const std::string& filename) const;
-
-private: // native image
-
- /**
- * @copydoc Dali::NativeImage::GlExtensionCreate()
- */
- virtual bool GlExtensionCreate();
-
- /**
- * @copydoc Dali::NativeImage::GlExtensionDestroy()
- */
- virtual void GlExtensionDestroy();
-
- /**
- * @copydoc Dali::NativeImage::TargetTexture()
- */
- virtual unsigned int TargetTexture();
-
- /**
- * @copydoc Dali::NativeImage::PrepareTexture()
- */
- virtual void PrepareTexture();
-
- /**
- * @copydoc Dali::NativeImage::GetWidth()
- */
- virtual unsigned int GetWidth() const;
-
- /**
- * @copydoc Dali::NativeImage::GetHeight()
- */
- virtual unsigned int GetHeight() const;
-
- /**
- * @copydoc Dali::NativeImage::GetPixelFormat()
- */
- virtual Pixel::Format GetPixelFormat() const;
-
-private:
-
- /**
- * @brief Private constructor
- * @param[in] width The width of the image.
- * @param[in] height The height of the image.
- * @param[in] depth color depth of the pixmap
- * @param[in] adaptor a reference to Dali adaptor
- * @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
- */
- PixmapImage(unsigned int width, unsigned int height, ColorDepth depth, Adaptor& adaptor, Any pixmap);
-
- /**
- * @brief A reference counted object may only be deleted by calling Unreference().
- *
- * The implementation should destroy the NativeImage resources.
- */
- virtual ~PixmapImage();
-
- /**
- * @brief Undefined assignment operator.
- *
- * This avoids accidental calls to a default assignment operator.
- * @param[in] rhs A reference to the object to copy.
- */
- PixmapImage& operator=(const PixmapImage& rhs);
-
-private:
-
- Internal::Adaptor::PixmapImage* mImpl; ///< Implementation pointer
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_PIXMAP_IMAGE_H__
+++ /dev/null
-#ifndef __DALI_RENDER_SURFACE_H__
-#define __DALI_RENDER_SURFACE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/object/any.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-/**
- * @brief The position and size of the render surface.
- */
-typedef Dali::Rect<int> PositionSize;
-
-/**
- * @brief Interface for a render surface onto which Dali draws.
- *
- * Dali::Adaptor requires a render surface to draw on to. This is
- * usually a window in the native windowing system, or some other
- * mapped pixel buffer.
- *
- * Dali::Application will automatically create a render surface using a window.
- *
- * The implementation of the factory method below should choose an appropriate
- * implementation of RenderSurface for the given platform
- */
-class RenderSurface
-{
-public:
- /**
- * @brief enumeration of surface types
- */
- enum SurfaceType
- {
- NO_SURFACE, ///< not configured
- PIXMAP, ///< Pixmap
- WINDOW, ///< Window
- NATIVE_BUFFER ///< Native Buffer
- };
-
- /**
- * @brief When application uses pixmap surface, it can select rendering mode.
- *
- * RENDER_SYNC : application should call RenderSync() after posting the offscreen to onscreen
- * RENDER_#FPS : the maximum performance will be limited designated number of frame
- */
- enum RenderMode
- {
- RENDER_DEFAULT = -1,
- RENDER_SYNC = 0,
- RENDER_24FPS = 24,
- RENDER_30FPS = 30,
- RENDER_60FPS = 60
- };
-
- /**
- * @brief Constructor
- *
- * Application or Adaptor needs to create the appropriate concrete RenderSurface type.
- * @see CreateDefaultSurface
- */
- RenderSurface();
-
- /**
- * @brief Virtual Destructor.
- */
- virtual ~RenderSurface();
-
- /**
- * @brief returns the surface type.
- * @return the surface type
- */
- virtual SurfaceType GetType() = 0;
-
- /**
- * @brief Returns the window or pixmap surface.
- * @return surface
- */
- virtual Any GetSurface() = 0;
-
- /**
- * @brief Returns the display.
- * @return display
- */
- virtual Any GetDisplay() = 0;
-
- /**
- * @brief Return the size and position of the surface.
- * @return The position and size
- */
- virtual PositionSize GetPositionSize() const = 0;
-
- /**
- * @brief Set frame update rate for pixmap surface type
- */
- virtual void SetRenderMode(RenderMode mode) = 0;
-
- /**
- * @brief Get current fps for pixmap surface type
- * @return The render mode
- */
- virtual RenderMode GetRenderMode() const = 0;
-
-private:
-
- /**
- * @brief Undefined copy constructor. RenderSurface cannot be copied
- */
- RenderSurface( const RenderSurface& rhs );
-
- /**
- * @brief Undefined assignment operator. RenderSurface cannot be copied
- */
- RenderSurface& operator=( const RenderSurface& rhs );
-
-};
-
-/**
- * @brief Default surface factory function.
- *
- * A surface is created with the given type.
- *
- * @param [in] type the type of surface to create
- * @param [in] positionSize the position and size of the surface to create
- * @param [in] name optional name of surface passed in
- * @return The render surface
- */
-RenderSurface* CreateDefaultSurface( RenderSurface::SurfaceType type, PositionSize positionSize, const std::string& name = "" );
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_RENDER_SURFACE_H__
+++ /dev/null
-#ifndef __DALI_SOUND_PLAYER_H__
-#define __DALI_SOUND_PLAYER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class SoundPlayer;
-}
-}
-
-/**
- * @brief Plays sound effects.
- */
-class SoundPlayer : public BaseHandle
-{
-public:
-
- typedef SignalV2< void (SoundPlayer&) > SoundPlayFinishedSignalV2; ///< Sound play finished signal
-
- // Signal Names
- static const char* const SIGNAL_SOUND_PLAY_FINISHED; ///< name "sound-play-finished"
-
-public:
-
- /**
- * @brief Create an uninitialized handle.
- *
- * This can be initialized by calling SoundPlayer::Get().
- */
- SoundPlayer();
-
- /**
- * @brief Create an initialized handle to the SoundPlayer.
- *
- * @return A handle to a newly allocated Dali resource.
- */
- static SoundPlayer Get();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~SoundPlayer();
-
- /**
- * @brief Plays a sound file.
- *
- * @pre The SoundPlayer needs to be initialized.
- * @param[in] fileName Path to the sound file to play.
- * @return a handle to the currently playing sound file which can be used to stop.
- */
- int PlaySound(const std::string fileName);
-
- /**
- * @brief Stops the currently playing sound.
- *
- * @pre The SoundPlayer needs to be initialized.
- * @param[in] handle
- */
- void Stop(int handle);
-
- /**
- * @brief This signal will be emitted after a given sound file is completely played.
- *
- * @pre The SoundPlayer needs to be initialized.
- * @return The signal to connect to.
- */
- SoundPlayFinishedSignalV2& SoundPlayFinishedSignal();
-
-public: // Not intended for application developers
-
- /**
- * @brief This constructor is used by SoundPlayer::Get().
- *
- * @param[in] soundPlayer A pointer to the sound player.
- */
- SoundPlayer( Internal::Adaptor::SoundPlayer* soundPlayer );
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_SOUND_PLAYER_H__
+++ /dev/null
-#ifndef __DALI_STYLE_CHANGE_H__
-#define __DALI_STYLE_CHANGE_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-namespace Dali DALI_IMPORT_API
-{
-
-/**
- * @brief Used to describe what style information has changed.
- *
- * This structure is used when any style changes occur and contains information about what exactly
- * has changed.
- */
-struct StyleChange
-{
- // Data
-
- bool defaultFontChange:1; ///< Denotes that the default font has changed.
- bool defaultFontSizeChange:1; ///< Denotes that the default font size has changed.
- bool themeChange:1; ///< Denotes that the theme has changed.
- std::string themeFilePath; ///< Contains the path to the new theme file.
-
- // Construction
-
- /**
- * @brief Default Constructor.
- */
- StyleChange()
- : defaultFontChange(false),
- defaultFontSizeChange(false),
- themeChange(false)
- {
- }
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_STYLE_CHANGE_H__
+++ /dev/null
-#ifndef __DALI_STYLE_MONITOR_H__
-#define __DALI_STYLE_MONITOR_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-#include <string>
-
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/common/style-change.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class StyleMonitor;
-}
-}
-
-/**
- * @brief Monitors the platform for style changes.
- *
- * This is a handle to the adaptor's style monitor which holds the platform's style information.
- * It provides a signal when any aspect of the default style changes on the device.
- * @see Adaptor::GetStyleMonitor
- */
-class StyleMonitor : public BaseHandle
-{
-public: // Typedefs
-
- typedef SignalV2< void (StyleMonitor, StyleChange) > StyleChangeSignalV2; ///< StyleChange Signal type
-
-public: // Creation & Destruction
-
- /**
- * @brief Create an uninitialized StyleMonitor handle.
- *
- * Tthis can be set by retrieving the style monitor from the Adaptor
- * or the Application classes. Calling member functions when
- * uninitialized is not allowed.
- */
- StyleMonitor();
-
- /**
- * @brief Creates a copy of the handle.
- *
- * The copy will point to the same implementation as the original.
- * @param[in] monitor The Style Monitor to copy from.
- */
- StyleMonitor(const StyleMonitor& monitor);
-
- /**
- * @brief Retrieve the initialized instance of the StyleMonitor.
- * @return Handle to StyleMonitor.
- */
- static StyleMonitor Get();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~StyleMonitor();
-
- /**
- * @brief Downcast an Object handle to StyleMonitor handle.
- *
- * If handle points to a StyleMonitor object the downcast produces a
- * valid handle. If not the returned handle is left uninitialized.
- *
- * @param[in] handle to An object @return handle to a Timer object
- * or an uninitialized handle
- */
- static StyleMonitor DownCast( BaseHandle handle );
-
- /**
- * @copydoc Dali::BaseHandle::operator=
- */
- using BaseHandle::operator=;
-
-public: // Style Information
-
- /**
- * @brief Retrieves the default font family.
- * @return The default font family.
- */
- std::string GetDefaultFontFamily() const;
-
- /**
- * @brief Retrieves the default font size
- * @return The default font size.
- */
- float GetDefaultFontSize() const;
-
- /**
- * @brief Retrieves the user defined Theme.
- * @return The user defined Theme.
- */
- const std::string& GetTheme() const;
-
- /**
- * @brief Sets an user defined Theme.
- * @param[in] themeFilePath Path of the user defined theme
- */
- void SetTheme(const std::string& themeFilePath);
-
-public: // Signals
-
- /**
- * @brief This signal is emitted whenever the style changes on the device.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallbackName(StyleMonitor styleMonitor, StyleChange change);
- * @endcode
- * @return The signal to connect to.
- */
- StyleChangeSignalV2& StyleChangeSignal();
-
-public: // Operators
-
- /**
- * @brief Assignment operator.
- *
- * The handle points to the same implementation as the one being copied from.
- * @param[in] monitor The Style Monitor to copy from.
- * @return reference to this object
- */
- StyleMonitor& operator=(const StyleMonitor& monitor);
-
-
-public: // Not intended for application developers
- /**
- * @brief This constructor is used internally to create a handle from an object pointer.
- * @param [in] styleMonitor A pointer the internal style monitor.
- */
- explicit DALI_INTERNAL StyleMonitor(Internal::Adaptor::StyleMonitor* styleMonitor);
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_STYLE_MONITOR_H__
+++ /dev/null
-#ifndef __DALI_TIMER_H__
-#define __DALI_TIMER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class Timer;
-}
-}
-
-/**
- * @brief Mechanism to issue simple periodic or one-shot events.
- *
- * Timer is provided for application developers to be able to issue
- * simple periodic or one-shot events. Please note that timer
- * callback functions should return as soon as possible, because they
- * block the next SignalTick. Please note that timer signals are not
- * in sync with Dali's render timer.
- *
- * This class is a handle class so it can be stack allocated and used
- * as a member.
- */
-class Timer : public BaseHandle
-{
-public: // Signal typedefs
-
- typedef SignalV2< bool () > TimerSignalV2; ///< Timer finished signal callback type
-
-public: // API
-
- /**
- * @brief Constructor, creates an uninitialized timer.
- *
- * Call New to fully construct a timer.
- */
- Timer();
-
- /**
- * @brief Create an tick Timer that emits periodic signal.
- *
- * @param[in] milliSec Interval in milliseconds.
- * @return a new timer
- */
- static Timer New( unsigned int milliSec );
-
- /**
- * @brief Copy constructor.
- *
- * @param[in] timer The handle to copy. The copied handle will point at the same implementation
- */
- Timer( const Timer& timer );
-
- /**
- * @brief Assignment operator.
- *
- * @param[in] timer The handle to copy. This handle will point at the same implementation
- * as the copied handle.
- * @return Reference to this timer handle
- */
- Timer& operator=( const Timer& timer );
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~Timer();
-
- /**
- * @brief Downcast an Object handle to Timer handle.
- *
- * If handle points to a Timer object the downcast produces a valid
- * handle. If not the returned handle is left uninitialized.
- *
- * @param[in] handle to An object
- * @return handle to a Timer object or an uninitialized handle
- */
- static Timer DownCast( BaseHandle handle );
-
- /**
- * @copydoc Dali::BaseHandle::operator=
- */
- using BaseHandle::operator=;
-
- /**
- * @brief Start timer.
- *
- * In case a Timer is already running it's time is reset and timer is restarted.
- */
- void Start();
-
- /**
- * @brief Stop timer.
- */
- void Stop();
-
- /**
- * @brief Sets a new interval on the timer and starts the timer.
- *
- * Cancels the previous timer.
- * @param milliSec Interval in milliseconds.
- */
- void SetInterval( unsigned int milliSec );
-
- /**
- * @brief Get the interval of timer.
- * @returns Interval in milliseconds.
- */
- unsigned int GetInterval() const;
-
- /**
- * @brief Tells whether timer is running.
- * @return Whether Timer is started or not.
- */
- bool IsRunning() const;
-
-public: // Signals
-
- /**
- * @brief Signal emitted after specified time interval.
- *
- * The return of the callback decides whether signal emission stops or continues.
- * If the callback function returns false emission will stop, if true it will continue
- * This return value is ignored for one-shot events, which will always stop after the first execution.
- * @returns The signal to Connect() with.
- */
- TimerSignalV2& TickSignal();
-
-public: // Not intended for application developers
- explicit DALI_INTERNAL Timer(Internal::Adaptor::Timer* timer);
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_TIMER_H__
+++ /dev/null
-#ifndef __DALI_TTS_PLAYER_H__
-#define __DALI_TTS_PLAYER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-handle.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class TtsPlayer;
-}
-}
-
-/**
- * @brief The Text-to-speech Player.
- */
-class TtsPlayer : public BaseHandle
-{
-public: // ENUMs
-
- /**
- * @brief Enumeration of TTS mode.
- */
- enum Mode
- {
- DEFAULT = 0, ///< Default mode for normal application
- NOTIFICATION, ///< Notification mode
- SCREEN_READER, ///< Screen reader mode
- MODE_NUM
- };
-
-public: // API
-
- /**
- * @brief Create an uninitialized handle.
- *
- * This can be initialized by calling TtsPlayer::Get().
- */
- TtsPlayer();
-
- /**
- * @brief Gets the singleton of the TtsPlayer for each mode.
- *
- * Internally, each tts player handles (singleton instance) are managed for each mode.
- * @param mode the mode of tts-player
- * @return A handle of the Ttsplayer for given mode.
- */
- static TtsPlayer Get(Dali::TtsPlayer::Mode mode = Dali::TtsPlayer::DEFAULT);
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~TtsPlayer();
-
- /**
- * @brief Start playing the audio data synthesized from the specified text.
- *
- * @pre The TtsPlayer needs to be initialized.
- * @param[in] text to play.
- */
- void Play(const std::string& text);
-
- /**
- * @brief Stops playing the utterance.
- * @pre The TtsPlayer needs to be initialized.
- */
- void Stop();
-
- /**
- * @brief Pauses the currently playing utterance.
- * @pre The TtsPlayer needs to be initialized.
- */
- void Pause();
-
- /**
- * @brief Resumes the previously paused utterance.
- * @pre The TtsPlayer needs to be initialized.
- */
- void Resume();
-
-public: // Not intended for application developers
-
- /**
- * @brief This constructor is used by TtsPlayer::Get().
- * @param[in] ttsPlayer A pointer to the TTS player.
- */
- TtsPlayer( Internal::Adaptor::TtsPlayer* ttsPlayer );
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_TTS_PLAYER_H__
+++ /dev/null
-#ifndef __DALI_VIRTUAL_KEYBOARD_H__
-#define __DALI_VIRTUAL_KEYBOARD_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/signals/dali-signal-v2.h>
-#include <dali/public-api/math/rect.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-/**
- * @brief This namespace is provided for application developers to be able to show and hide the on-screen keyboard.
- *
- * Key events are sent to the actor in focus. Focus is set through the actor Public API.
- */
-namespace VirtualKeyboard
-{
-
-// Types
-
-typedef SignalV2< void () > VoidSignalV2;
-typedef SignalV2< void (bool) > StatusSignalV2;
-
-// Enumerations
-
-/**
- * @brief The direction of text.
- */
-enum TextDirection
-{
- LeftToRight,
- RightToLeft,
-};
-
-/**
- * @brief The meaning of the return key.
- */
-enum ReturnKeyType
-{
- DEFAULT,
- DONE,
- GO,
- JOIN,
- LOGIN,
- NEXT,
- SEARCH,
- SEND,
- SIGNIN
-};
-
-// Functions
-/**
- * @brief Show the virtual keyboard.
- */
-void Show();
-
-/**
- * @brief Hide the virtual keyboard.
- */
-void Hide();
-
-/**
- * @brief Returns whether the virtual keyboard is visible or not.
- * @return true if visible, false otherwise.
- */
-bool IsVisible();
-
-/**
- * @brief Set the specific return key into the virtual keyboard.
- * @param[in] type the kind of return key types.
- */
-void SetReturnKeyType( ReturnKeyType type );
-
-/**
- * @brief Retrieve the current return key type.
- * @return the type of retun key.
- */
-ReturnKeyType GetReturnKeyType();
-
-/**
- * @brief Enable/disable prediction (predictive text).
- *
- * By default prediction text is enabled.
- * @param[in] enable true or false to enable or disable
- * Prediction can not be changed while the keyboard is visible. It must be set in advance of showing keyboard.
- */
-void EnablePrediction(const bool enable);
-
-/**
- * @brief Returns whether prediction is enabled in the virtual keyboard
- * @return true if predictive text enabled, false otherwise.
- */
-bool IsPredictionEnabled();
-
-/**
- * @brief Provides size and position of keyboard.
- *
- * Position is relative to whether keyboard is visible or not.
- * If keyboard is not visible then position will be off the screen.
- * If keyboard is not being shown when this method is called the keyboard is partially setup (IMFContext) to get
- * the values then taken down. So ideally GetSizeAndPosition() should be called after Show().
- * @return rect which is keyboard panel x, y, width, height
- */
-Dali::Rect<int> GetSizeAndPosition();
-
-/**
- * @brief Rotates the keyboard orientation to the given angle.
- *
- * A value of 0 indicates the portrait orientation.
- * Other valid values are 90, 180, 270.
- * @param angle the angle is in degrees.
- */
-void RotateTo(int angle);
-
-/**
- * @brief Returns text direction of the keyboard's current input language.
- * @return The direction of the text.
- */
-TextDirection GetTextDirection();
-
-/**
- * @brief Connect to this signal to be notified when the virtual keyboard is shown or hidden.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallbackName(bool keyboardShown);
- * @endcode
- * If the parameter keyboardShown is true, then the keyboard has just shown, if it is false, then it
- * has just been hidden.
- * @return The signal to connect to.
- */
-StatusSignalV2& StatusChangedSignal();
-
-/**
- * @brief Connect to this signal to be notified when the virtual keyboard is resized.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallbackName();
- * @endcode
- * User can get changed size by using GetSizeAndPosition() in the callback
- * @return The signal to connect to.
- */
-VoidSignalV2& ResizedSignal();
-
-/**
- * @brief Connect to this signal to be notified when the virtual keyboard's language is changed.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallbackName();
- * @endcode
- * User can get the text direction of the language by calling GetTextDirection() in the callback.
- * @return The signal to connect to.
- */
-VoidSignalV2& LanguageChangedSignal();
-
-} // namespace VirtualKeyboard
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_VIRTUAL_KEYBOARD_H__
+++ /dev/null
-#ifndef __DALI_WINDOW_H__
-#define __DALI_WINDOW_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/object/base-handle.h>
-
-namespace Dali DALI_IMPORT_API
-{
-typedef Dali::Rect<int> PositionSize;
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class Window;
-}
-}
-
-class DragAndDropDetector;
-class Orientation;
-
-/**
- * @brief The window class is used internally for drawing.
- *
- * It has an orientation
- * and indicator properties.
- */
-class Window : public BaseHandle
-{
-public:
-
- // Enumerations
-
- /**
- * @brief Orientation of the window.
- */
- enum WindowOrientation
- {
- PORTRAIT = 0,
- LANDSCAPE = 90,
- PORTRAIT_INVERSE = 180,
- LANDSCAPE_INVERSE = 270
- };
-
- /**
- * @brief Opacity of the indicator.
- */
- enum IndicatorBgOpacity
- {
- OPAQUE = 100, // Fully opaque indicator Bg
- TRANSLUCENT = 50, // Semi translucent indicator Bg
- TRANSPARENT = 0 // Fully transparent indicator Bg
- };
-
- /**
- * @brief Visible mode of the indicator.
- */
- enum IndicatorVisibleMode
- {
- INVISIBLE = 0, // hide indicator
- VISIBLE = 1, // show indicator
- AUTO = 2 // hide in default, will show when necessary
- };
-
- /**
- * @brief Style of the indicator.
- */
- enum IndicatorStyle
- {
- FIXED_COLOR = 0, // fixed color style
- CHANGEABLE_COLOR // changeable color style
- };
-
- // Methods
-
- /**
- * @brief Create an initialized handle to a new Window.
- * @param[in] windowPosition The position and size of the window
- * @param[in] name The window title
- * @param[in] isTransparent Whether window is transparent
- * @return a new window
- */
- static Window New(PositionSize windowPosition, std::string name, bool isTransparent = false);
-
- /**
- * @brief Create an uninitalized handle.
- *
- * This can be initialized using Dali::Application::GetWindow() or
- * Dali::Window::New()
- */
- Window();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~Window();
-
- /**
- * @copydoc Dali::BaseHandle::operator=
- */
- using BaseHandle::operator=;
-
- /**
- * @brief This sets the style of indicator
- * @param[in] style style type of the indicator
- *
- * @note This should be called before ShowIndicator()
- */
- void SetIndicatorStyle( IndicatorStyle style );
-
- /**
- * @brief This sets whether the indicator bar should be shown or not.
- * @param[in] show - true if the indicator bar should be shown
- * @deprecated use "void ShowIndicator( IndicatorVisibleMode visibleMode )"
- */
- void ShowIndicator( bool show );
-
- /**
- * @brief This sets whether the indicator bar should be shown or not.
- * @param[in] visibleMode visible mode for indicator bar, VISIBLE in default
- */
- void ShowIndicator( IndicatorVisibleMode visibleMode );
-
- /**
- * @brief This sets the opacity mode of indicator bar.
- * @param[in] opacity - The opacity mode
- */
- void SetIndicatorBgOpacity( IndicatorBgOpacity opacity );
-
- /**
- * @brief This sets the orientation of indicator bar.
- *
- * It does not implicitly show the indicator if it is currently
- * hidden.
- * @param[in] orientation The orientation
- */
- void RotateIndicator(WindowOrientation orientation);
-
- /**
- * @brief Set the window name and class string.
- * @param[in] name The name of the window
- * @param[in] klass The class of the window
- */
- void SetClass(std::string name, std::string klass);
-
- /**
- * @brief Raise window to top of window stack.
- */
- void Raise();
-
- /**
- * @brief Lower window to bottom of window stack.
- */
- void Lower();
-
- /**
- * @brief Activate window to top of window stack even it is iconified.
- */
- void Activate();
-
- /**
- * @brief Get the orientation class ( to allow signal connection ).
- */
- Orientation GetOrientation();
-
- /**
- * @brief Add an orientation to the list of available orientations.
- */
- void AddAvailableOrientation( WindowOrientation orientation );
-
- /**
- * @brief Remove an orientation from the list of available orientations.
- */
- void RemoveAvailableOrientation( WindowOrientation orientation );
-
- /**
- * @brief Set the orientations that this window can rotate to.
- *
- * By default, the window does not change orientation.
- * @param[in] orientations The list of orientations
- */
- void SetAvailableOrientations( const std::vector<WindowOrientation>& orientations );
-
- /**
- * @brief Get the list of orientations this window can rotate to.
- * @return the list of orientations
- */
- const std::vector<WindowOrientation>& GetAvailableOrientations();
-
- /**
- * @brief Set a preferred orientation.
- * @pre orientation is in the list of available orientations
- * @param[in] orientation The preferred orientation
- */
- void SetPreferredOrientation( WindowOrientation orientation );
-
- /**
- * @brief Get the preferred orientation.
- * @return The preferred orientation if previously set, or none.
- */
- WindowOrientation GetPreferredOrientation();
-
- /**
- * @brief Returns the Drag & drop detector which can be used to receive drag & drop events.
- * @return A handle to the DragAndDropDetector.
- */
- DragAndDropDetector GetDragAndDropDetector() const;
-
-public: // Not intended for application developers
- /**
- * @brief This constructor is used by Dali::Application::GetWindow().
- * @param[in] window A pointer to the window.
- */
- explicit Window( Internal::Adaptor::Window* window );
-};
-
-} // namespace Dali
-
-
-/**
- * @}
- */
-#endif // __DALI_WINDOW_H__
+++ /dev/null
-#ifndef __DALI_EVAS_PLUGIN_H__
-#define __DALI_EVAS_PLUGIN_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <boost/function.hpp>
-
-#include <dali/public-api/signals/dali-signal-v2.h>
-
-// Declare this forward declaration ourselves to remove unnecessary dependencies in
-// public headers.
-extern "C"
-{
- struct _Evas_Object;
- typedef struct _Evas_Object Evas_Object; ///< Forward declaration of Evas_Object
-}
-
-
-namespace Dali DALI_IMPORT_API
-{
-class Adaptor;
-
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
-{
-class EvasPlugin;
-}
-}
-
-/**
- * @brief Application class used by EFL applications that wish to use Dali.
- *
- * An EvasPlugin class object should be created by EFL application
- * that wishes to use Dali. It provides a means for initialising the
- * resources required by the Dali::Core.
- *
- * The EvasPlugin class emits several signals which the user can
- * connect to. The user should not create any Dali objects in the main
- * function and instead should connect to the Init signal of the
- * EvasPlugin and create the Dali objects in the connected callback.
- *
- * SLP and EFL applications should follow the example below:
- *
- * @code
- * void Created(EvasPlugin& evasPlugin)
- * {
- * // Create Dali components...
- * // Can instantiate here, if required
- * }
- *
- * void Resized(EvasPlugin& evasPlugin)
- * {
- * // Set size properties of Dali components
- * // Set screen layout
- * }
- *
- * int main (int argc, char **argv)
- * {
- * elm_init(&argc, &argv);
- *
- * Evas* e;
- * Evas_Object* win, eo;
- * win = elm_win_add(...);
- * Dali::EvasPlugin evasPlugin = Dali::EvasPlugin(win);
- * evasPlugin.InitSignal().Connect(&Created);
- * evasPlugin.ResizeSignal().Connect(&Resized);
- *
- * eo = evasPlugin.GetEvasImageObject();
- * evas_object_show(eo);
- *
- * // add eo to layout such as elm_box
- *
- * elm_run();
- * }
- * @endcode
- *
- * If required, you can also connect class member functions to a signal:
- *
- * @code
- * MyEvasPlugin mep;
- * mep.ResumeSignal().Connect(&app, &MyEvasPlugin::Resume);
- * @endcode
- */
-class EvasPlugin : public ConnectionTrackerInterface
-{
-public:
-
- typedef SignalV2< void (EvasPlugin&) > EvasPluginSignalV2; ///< Generic evas plugin signal type
-
-public:
-
- /**
- * @brief This is the constructor for SLP EFL applications
- * @param[in] parent A parent of new evas object
- * @param[in] isTransparent Whether the object is transparent or not
- * @param[in] initialWidth The initial width of Dali view port
- * @param[in] initialHeight The initial height of Dali view port
- */
- EvasPlugin(Evas_Object* parent, bool isTransparent = false, unsigned int initialWidth = 1, unsigned int initialHeight = 1);
-
- /**
- * @brief Virtual destructor.
- */
- virtual ~EvasPlugin();
-
-public:
-
- /**
- * @brief Run Evas Plugin.
- */
- void Run();
-
- /**
- * @brief Pause Evas Plugin.
- */
- void Pause();
-
- /**
- * @brief Resume Evas Plugin.
- */
- void Resume();
-
- /**
- * @brief Stop Evas Plugin.
- */
- void Stop();
-
- /**
- * @brief This returns Evas_Object* which is created internally.
- * @return Evas_Object* evas image object which is drawen by dali.
- */
- Evas_Object* GetEvasImageObject();
-
- /**
- * @brief This returns Evas_Object* which is created internally.
- *
- * Application should append this access object to custom focus chain for accessibility
- *
- * e.g. elm_object_focus_custom_chain_append(layout, dali_access_object, NULL);
- *
- * @return Evas_Object* elm access object which dali image object is registered.
- */
- Evas_Object* GetElmAccessObject();
-
- /**
- * @brief This returns Evas_Object* which is created internally.
- *
- * If application want to handle the keyboard focus among the efl and dali view part,
- * application should set this object to efl layout instead of the evas image object from GetEvasImageObject()
- * @return Evas_Object* evas object which can handle the focus internally. It is contained the image object.
- */
- Evas_Object* GetElmFocusObject();
-
- /**
- * @brief This returns the internal Adaptor instance.
- *
- * @return Adaptor* adaptor instance.
- */
- Dali::Adaptor* GetAdaptor();
-
-public: // Signals
-
- /**
- * @brief Signal to notify the client when the application is ready to be initialized.
- * @return The signal
- */
- EvasPluginSignalV2& InitSignal();
-
- /**
- * @brief Signal to notify client when Dali has rendered at least one frame.
- *
- * The user should connect to this signal to be notified when Dali has started rendering
- * and atleast one frame has been rendered.
- * @return The signal
- */
- EvasPluginSignalV2& FirstRenderCompletedSignal();
-
- /**
- * @brief Signal to notify the user when the application is about to be terminated.
- *
- * @return The signal
- */
- EvasPluginSignalV2& TerminateSignal();
-
- /**
- * @brief Signal to notify the client when the adaptor is about to be paused.
- *
- * The user should connect to this signal if they need to perform any special
- * activities when the application is about to be paused.
- * @return The signal
- */
- EvasPluginSignalV2& PauseSignal();
-
- /**
- * @brief Signal to notify the client when the adpator has resumed.
- *
- * The user should connect to this signal if they need to perform any special
- * activities when the application has resumed.
- * @return The signal
- */
- EvasPluginSignalV2& ResumeSignal();
-
- /**
- * @brief Signal to notify the client when the evas object is resized.
- * @return The signal
- */
- EvasPluginSignalV2& ResizeSignal();
-
- /**
- * @brief Signal to notify the client when the evas object get the keyboard focus.
- * @return The signal
- */
- EvasPluginSignalV2& FocusedSignal();
-
- /**
- * @brief Signal to notify the client when the evas object lost the keyboard focus.
- * @return The signal
- */
- EvasPluginSignalV2& UnFocusedSignal();
-
-protected:
- /**
- * @copydoc ConnectionTrackerInterface::SignalConnected
- */
- virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback );
-
- /**
- * @copydoc ConnectionTrackerInterface::SignalDisconnected
- */
- virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback );
-
- /**
- * @copydoc ConnectionTrackerInterface::GetConnectionCount
- */
- virtual std::size_t GetConnectionCount() const;
-
-private:
-
- // Undefined
- EvasPlugin(const EvasPlugin&);
- EvasPlugin& operator=(EvasPlugin&);
-
-private:
-
- Internal::Adaptor::EvasPlugin *mImpl; ///< Pointer to Implementation
- friend class Internal::Adaptor::EvasPlugin;
-};
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_EVAS_PLUGIN_H__
+++ /dev/null
-#ifndef __DALI_NATIVE_BUFFER_PLUGIN_H__
-#define __DALI_NATIVE_BUFFER_PLUGIN_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @addtogroup CAPI_DALI_ADAPTOR_MODULE
- * @{
- */
-
-// EXTERNAL INCLUDES
-#include <native-buffer-pool.h>
-#include <boost/function.hpp>
-
-#include <dali/public-api/signals/dali-signal-v2.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/adaptor-framework/common/render-surface.h>
-#include <dali/public-api/adaptor-framework/common/device-layout.h>
-
-namespace Dali DALI_IMPORT_API
-{
-
-class Adaptor;
-
-namespace Internal DALI_INTERNAL
-{
-
-namespace Adaptor
-{
-
-class NativeBufferPlugin;
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-/**
- * @brief Used by Tizen applications that wish to capture Dali output in a buffer.
- *
- * A NativeBufferPlugin class object should be created by Tizen application
- * that wish to use Dali, capturing it's output using the Native Buffer Provider API.
- * It provides a means for initialising the resources required by the Dali::Core.
- *
- * The NativeBufferPlugin class emits several signals which the user may
- * connect to. The user should not create any Dali objects in the main()
- * function and instead should connect to the InitSignal of the
- * NativeBufferPlugin and create DALi objects in the signal handler.
- *
- * Tizen applications should follow the example below:
- *
- * @code
- * void OnConsumeTimerCallback()
- * {
- * native_buffer* buffer = nbPlugin.GetNativeBufferFromOutput();
- * if(buffer != NULL)
- * {
- * // Consume the buffer
- * }
- * // return back the buffer to plugin
- * AddNativeBufferToInput(buffer);
- * }
- *
- * void Created(NativeBufferPlugin& nbPlugin)
- * {
- * // Create Dali components...
- * // Can instantiate here, if required
- * mTimer = Dali::Timer::New(1000/30); // 30fps
- * mTimer.TickSignal().Connect(this, &OnConsumeTimerCallback);
- * mTimer.Start();
- * }
- *
- * void Resized(NativeBufferPlugin& nbPlugin)
- * {
- * // Set size properties of Dali components
- * // Set screen layout
- * }
- *
- * int main (int argc, char **argv)
- * {
- * Dali::NativeBufferPlugin nbPlugin( 640, 480, false, 2, RENDER_30FPS );
- * nbPlugin.InitSignal().Connect(&Created);
- * nbPlugin.ResizeSignal().Connect(&Resized);
- * nbPlugin.Run();
- * }
- * @endcode
- */
-class NativeBufferPlugin
-{
-public:
-
- typedef SignalV2< void (NativeBufferPlugin&) > NativeBufferPluginSignalV2; ///< Generic native buffer signal type
-
-public:
-
- /**
- * @brief This is the constructor for Tizen applications.
- * @param[in] initialWidth The initial width of Dali view port
- * @param[in] initialHeight The initial height of Dali view port
- * @param[in] isTransparent Whether the surface will be transparent or not
- * @param[in] maxBufferCount The maximum number of buffers to render
- * @param[in] mode The rendering mode to decide frame rate
- * @param[in] baseLayout The base layout that the application has been written for
- */
- NativeBufferPlugin( unsigned int initialWidth, unsigned int initialHeight, bool isTransparent = false, unsigned int maxBufferCount = 2, RenderSurface::RenderMode mode = RenderSurface::RENDER_60FPS, const DeviceLayout& baseLayout = DeviceLayout::DEFAULT_BASE_LAYOUT);
-
- /**
- * @brief Virtual destructor.
- */
- virtual ~NativeBufferPlugin();
-
-public:
-
- /**
- * @brief Run the NativeBufferPlugin.
- */
- void Run();
-
- /**
- * @brief Pause the NativeBufferPlugin.
- */
- void Pause();
-
- /**
- * @brief Resume the NativeBufferPlugin.
- */
- void Resume();
-
- /**
- * @brief Stop the NativeBufferPlugin.
- */
- void Stop();
-
- /**
- * @brief Get the internal Adaptor instance.
- * @return A pointer to the internal adaptor instance.
- */
- Dali::Adaptor* GetAdaptor();
-
- /**
- * @brief Get the native buffer object which contain rendered result.
- *
- * Application should return back the buffer object to plugin by using AddNativeBufferToInput().
- * @return A pointer to the native buffer object.
- * @note do not destroy the native-buffer returned from this plugin.
- */
- native_buffer* GetNativeBufferFromOutput();
-
- /**
- * @brief Add the native buffer object which was consumed in application.
- *
- * The added buffer will be re-used with render target
- * @param nativeBuffer A pointer to the native buffer object.
- * @return True if the operation is successful
- * @pre the nativeBuffer should be got by GetNativeBufferFromOutput()
- */
- bool AddNativeBufferToInput(native_buffer* nativeBuffer);
-
- /**
- * @brief Get number of native buffers in pool.
- * @return vector2 which has input buffer count and output buffer count
- */
- Vector2 GetBufferCount();
-
- /**
- * @brief Change surface size.
- *
- * NOT YET SUPPORTED
- * @param width The width of target size
- * @param height The height of target size
- */
- void ChangeSurfaceSize(unsigned int width, unsigned int height);
-
-public: // Signals
-
- /**
- * @brief Signal to notify the client when the application is ready to be initialized.
- * @return The signal
- */
- NativeBufferPluginSignalV2& InitSignal();
-
- /**
- * @brief Signal to notify the user when the application is about to be terminated.
- * @return The signal
- */
- NativeBufferPluginSignalV2& TerminateSignal();
-
- /**
- * @brief Signal to notify the client when the adaptor is about to be paused.
- *
- * The user should connect to this signal if they need to perform any special
- * activities when the application is about to be paused.
- * @return The signal
- */
- NativeBufferPluginSignalV2& PauseSignal();
-
- /**
- * @brief Signal to notify the client when the adpator has resumed.
- *
- * The user should connect to this signal if they need to perform any special
- * activities when the application has resumed.
- * @return The signal
- */
- NativeBufferPluginSignalV2& ResumeSignal();
-
- /**
- * @brief Signal to notify the client when Dali has rendered at least one frame.
- *
- * The user should connect to this signal to be notified when Dali has started rendering
- * and atleast one frame has been rendered.
- * @return The signal
- */
- NativeBufferPluginSignalV2& FirstRenderCompletedSignal();
-
- /**
- * @brief Signal to notify the client when Dali has rendered one frame
- * @return The signal
- */
- NativeBufferPluginSignalV2& RenderSignal();
-
-private:
-
- // Undefined copy constructor
- NativeBufferPlugin(const NativeBufferPlugin&);
-
- // Undefined assignment operator
- NativeBufferPlugin& operator=(NativeBufferPlugin&);
-
-private:
-
- Internal::Adaptor::NativeBufferPlugin *mImpl; ///< Pointer to implementation
- friend class Internal::Adaptor::NativeBufferPlugin;
-
-}; // class NativeBufferPlugin
-
-} // namespace Dali
-
-/**
- * @}
- */
-#endif // __DALI_NATIVE_BUFFER_PLUGIN_H__
+++ /dev/null
-#ifndef __DALI_ADAPTOR_CAPI_INTERNAL_H__
-#define __DALI_ADAPTOR_CAPI_INTERNAL_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// These defines come from running pkg-config --cflags with the correct package config file
-
-#if defined(DALI_EVAS_PLUGIN)
-#include <dali/public-api/adaptor-framework/evas-plugin.h>
-#endif
-
-#if defined(DALI_NATIVE_BUFFER_PLUGIN)
-#include <dali/public-api/adaptor-framework/native-buffer-plugin.h>
-#endif
-
-#include <dali/public-api/adaptor-framework/common/accessibility-manager.h>
-#include <dali/public-api/adaptor-framework/common/adaptor.h>
-#include <dali/public-api/adaptor-framework/common/clipboard.h>
-#include <dali/public-api/adaptor-framework/common/clipboard-event-notifier.h>
-#include <dali/public-api/adaptor-framework/common/device-layout.h>
-#include <dali/public-api/adaptor-framework/common/drag-and-drop-detector.h>
-#include <dali/public-api/adaptor-framework/common/haptic-player.h>
-#include <dali/public-api/adaptor-framework/common/imf-manager.h>
-#include <dali/public-api/adaptor-framework/common/key.h>
-#include <dali/public-api/adaptor-framework/common/orientation.h>
-#include <dali/public-api/adaptor-framework/common/pixmap-image.h>
-#include <dali/public-api/adaptor-framework/common/render-surface.h>
-#include <dali/public-api/adaptor-framework/common/sound-player.h>
-#include <dali/public-api/adaptor-framework/common/style-change.h>
-#include <dali/public-api/adaptor-framework/common/style-monitor.h>
-#include <dali/public-api/adaptor-framework/common/timer.h>
-#include <dali/public-api/adaptor-framework/common/tts-player.h>
-#include <dali/public-api/adaptor-framework/common/virtual-keyboard.h>
-#include <dali/public-api/adaptor-framework/common/window.h>
-
-#endif //__DALI_ADAPTOR_CAPI_INTERNAL_H__
+++ /dev/null
-capi_evas_plugin_public_api_header_files = \
- $(capi_public_api_src_dir)/adaptor-framework/evas-plugin.h
-
-capi_native_buffer_plugin_public_api_header_files = \
- $(capi_public_api_src_dir)/adaptor-framework/native-buffer-plugin.h
-
-capi_adaptor_framework_common_header_files = \
- $(capi_src_dir)/adaptor-framework/common/accessibility-manager.h \
- $(capi_src_dir)/adaptor-framework/common/adaptor.h \
- $(capi_src_dir)/adaptor-framework/common/clipboard-event-notifier.h \
- $(capi_src_dir)/adaptor-framework/common/clipboard.h \
- $(capi_src_dir)/adaptor-framework/common/device-layout.h \
- $(capi_src_dir)/adaptor-framework/common/drag-and-drop-detector.h \
- $(capi_src_dir)/adaptor-framework/common/haptic-player.h \
- $(capi_src_dir)/adaptor-framework/common/imf-manager.h \
- $(capi_src_dir)/adaptor-framework/common/key.h \
- $(capi_src_dir)/adaptor-framework/common/orientation.h \
- $(capi_src_dir)/adaptor-framework/common/pixmap-image.h \
- $(capi_src_dir)/adaptor-framework/common/render-surface.h \
- $(capi_src_dir)/adaptor-framework/common/sound-player.h \
- $(capi_src_dir)/adaptor-framework/common/style-change.h \
- $(capi_src_dir)/adaptor-framework/common/style-monitor.h \
- $(capi_src_dir)/adaptor-framework/common/timer.h \
- $(capi_src_dir)/adaptor-framework/common/tts-player.h \
- $(capi_src_dir)/adaptor-framework/common/virtual-keyboard.h \
- $(capi_src_dir)/adaptor-framework/common/window.h
-
-capi_header_file = \
- $(capi_src_dir)/dali-adaptor-capi-internal.h
<manifest>
- <assign>
- <filesystem path="/usr/lib/*" label="_" />
- <filesystem path="/opt/usr/share/dali/glyphcache" label="dali" type="transmutable" />
- </assign>
<request>
- <domain name="dali"/>
+ <domain name="_"/>
</request>
</manifest>
+%bcond_with wayland
+
Name: dali-adaptor
Summary: The DALi Tizen Adaptor
Version: 1.0.0
BuildRequires: pkgconfig(aul)
BuildRequires: boost-devel
BuildRequires: giflib-devel
-BuildRequires: pkgconfig(xi)
BuildRequires: pkgconfig(fontconfig)
BuildRequires: pkgconfig(elementary)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: libjpeg-turbo-devel
BuildRequires: pkgconfig(evas)
-BuildRequires: pkgconfig(xfixes)
-BuildRequires: pkgconfig(xdamage)
-BuildRequires: pkgconfig(utilX)
BuildRequires: dali-devel
BuildRequires: dali-integration-devel
BuildRequires: libxml2-devel
BuildRequires: libdrm-devel
BuildRequires: pkgconfig(libexif)
BuildRequires: pkgconfig(capi-system-system-settings)
-BuildRequires: pkgconfig(gles20)
BuildRequires: pkgconfig(efl-assist)
BuildRequires: pkgconfig(libpng)
+%if %{with wayland}
+BuildRequires: pkgconfig(glesv2)
+BuildRequires: pkgconfig(egl)
+BuildRequires: pkgconfig(ecore-wayland)
+BuildRequires: pkgconfig(wayland-egl)
+BuildRequires: pkgconfig(wayland-client)
+%else
+BuildRequires: pkgconfig(xi)
+BuildRequires: pkgconfig(xfixes)
+BuildRequires: pkgconfig(xdamage)
+BuildRequires: pkgconfig(utilX)
+BuildRequires: pkgconfig(gles20)
+%endif
%description
The DALi Tizen Adaptor provides a Tizen specific implementation of the dali-core
CXXFLAGS+=" -D_ARCH_ARM_ -lgcc"
%endif
+%if %{with wayland}
+CFLAGS+=" -DWAYLAND"
+CXXFLAGS+=" -DWAYLAND"
+%endif
+
libtoolize --force
cd %{_builddir}/%{name}-%{version}/build/tizen && autoreconf --install
+%if %{with wayland}
+cd %{_builddir}/%{name}-%{version}/build/tizen && CXXFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS DALI_DATA_RW_DIR="%{dali_data_rw_dir}" DALI_DATA_RO_DIR="%{dali_data_ro_dir}" FONT_PRELOADED_PATH="%{font_preloaded_path}" FONT_DOWNLOADED_PATH="%{font_downloaded_path}" FONT_APPLICATION_PATH="%{font_application_path}" FONT_CONFIGURATION_FILE="%{font_configuration_file}" ./configure --prefix=$PREFIX --with-jpeg-turbo --enable-gles=20 --enable-profile=COMMON --enable-wayland
+%else
cd %{_builddir}/%{name}-%{version}/build/tizen && CXXFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS DALI_DATA_RW_DIR="%{dali_data_rw_dir}" DALI_DATA_RO_DIR="%{dali_data_ro_dir}" FONT_PRELOADED_PATH="%{font_preloaded_path}" FONT_DOWNLOADED_PATH="%{font_downloaded_path}" FONT_APPLICATION_PATH="%{font_application_path}" FONT_CONFIGURATION_FILE="%{font_configuration_file}" ./configure --prefix=$PREFIX --with-jpeg-turbo --enable-gles=20 --enable-profile=COMMON
-
+%endif
make %{?jobs:-j%jobs}
#endif
// INTERNAL INCLUDES
-#include <public-api/adaptor-framework/common/feedback-plugin.h>
+#include <feedback-plugin.h>
namespace Dali
{